I have a file with around 20000 columns as gene names. I want to grep out the rpkm values for specific genes. Is there a way to grep out the column information?

> sample &nbsp;&nbsp;&nbsp; gene17 &nbsp;&nbsp;&nbsp; gene92 &nbsp;&nbsp;&nbsp; gene1 ... gene20000

> patient1 &nbsp;&nbsp;&nbsp; 0.03569654 &nbsp;&nbsp;&nbsp; 1.020565 &nbsp;&nbsp;&nbsp; 0.0036522 ... 0.25247236


I only want gene72 for example, but it's not sorted in increasing order.

Thanks.
Hi,

in order to find the column number you can use:

    head -n 1 file | tr '\t' '\n' | cat -n | grep gene72
With `head -n 1` , you get only the file's first line. With `tr` you replace the tab-separator by a new line. With `cat -n`, you print the input with line numbers on which you use finally `grep` to get the column of interest.

with the found number - let it be j - you can use cut:

    cut -f 1,j file

Cheers,

Michael 