Reputation: 1201
I have a big but well formatted file 'A'. The first column stores the name of each row. I have another file 'B' stores the names which I am interested in. How can I select the rows having a name in file 'B'? This is simple in idea, but I am unfamiliar with LINUX.
File 'A': the data file. The first column is the name, separated with the 2nd column by \tab. The other columns are separated by comma.
col1 0.1111,0.2222,0.33333,0.4444
col2 0.1111,0.2222,0.33333,0.4444
col3 0.1111,0.2222,0.33333,0.4444
col4 0.1111,0.2222,0.33333,0.4444
File 'B': the rows with interest, stored in one column.
col1
col3
col4
Upvotes: 0
Views: 423
Reputation: 7552
grep in A for every line in B:
for f in `cat B`; do grep -w "^$f" A >> output.txt; done
or simpler
grep -f B A > output.txt
please note that the lines in B need to be valid regular experssions
Upvotes: 1