Hello,
I've file with 42847 tab sep columns. For demo purpose I'm going to put 6 columns.
Input data (6 columns)
ABCA7 INDO 0.0316847 LARS 0.0400374 ADCK4
CD33 INDO 0.0266461 LARS 0.0970214 ADCK4
TREM2 INDO 0.0179237 LARS 0.0998961 ADCK4
ABCA7 INDO 0.0316847 LARS 0.0400374 ADCK4
CR1 INDO 0.0151277 LARS 0.0378186 ADCK4
PTK2B INDO 0.0240611 LARS 0.0438327 ADCK4
cut -f -6 test_input_data.txt | grep "CR1" | gawk -v OFS='\t' '{ for (i;i<=NF ;i++) { if ( $i ~ /LARS/ ) {print i} } }'
I'm cutting 6 columns from input file so I can grep CR1.
Next I'm interested to get column number of LARS in the grepped output.
I get output as
4
1)
A blank line and 4. It looks OK, but I don't know why I get a blank line.
I got code from link