awk command to print multiple columns
0
0
Entering edit mode
3.6 years ago

I want to separate 4th column of comma separated list to new rows,

My file is like this

A   B   C   1,2 D   E

I want output like

A   B   C   1   D   E
A   B   C   2   D   E

I am using command as:

awk -F'\t' '{ n=split($4,arr,","); for(i=1;i<=n;i++) print $1"\t"$2"\t"$3"\t"arr[i]"\t"$5"\t"$6 }'

But original file contains 100 columns, so how to print all columns from 5 to 100 as it is not possible to write one by one

awk • 1.5k views
ADD COMMENT
0
Entering edit mode

how is it related to bioinformatics ?

ADD REPLY
0
Entering edit mode
ADD REPLY

Login before adding your answer.

Traffic: 3021 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6