awk command to print multiple columns
0
0
Entering edit mode
12 weeks 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 • 184 views
0
Entering edit mode

how is it related to bioinformatics ?

0
Entering edit mode

Collection of R solutions from SO: