unix - how to extract rows in a big table based on a list file containing the specific names in linux -
i have big data table (datatable.txt), snapshot below:
snpname chr position sample1 sample2 sample3 sample4 ....sample2000 rs1 1 1000 a b b ..... rs2 2 1500 b b ..... b rs3 3 1503 b b a ..... . . . . rs99999 22 999999 a ...... b
and have list of snpnames want include in output table (other snpnames not in list excluded). list (list.txt) below:
rs4560 rs4780 rs6 rs798 rs2634 rs987 rs1839 rs3948 rs2423 rs232
how can produce new output table contains snpnames listed in list file?
please advise, thank you. :)
you can use example this:
grep -wff list.txt datatable.txt
-w
matches words.-f
gets patterns filelist.txt
.-f
compares strings such, not possible regular expressions.
based on sample input, , changing rs3
rs6
have match, get:
$ grep -wff list.txt datatable.txt rs6 3 1503 b b a .....
Comments
Post a Comment