Entering edit mode
8.0 years ago
Janey
▴
30
Hi At first I thought that this work is so simple for me. I have File1 (ID list) and File2 (reference file). I want to extract some full rows by ID list from File2. I am not familiar to R and Python. I used "grep -f File1 File2" and some other commands but i got errors. Can anyone show me a simple solution to solve this problem.
man join / http://superuser.com/questions/25302
What errors did you get?
grep -f
is a pretty standard approach.Hi Alex I run this command "grep -f File1.txt (IDs) File2.txt(Ref) > output" several times for avoiding error but I output file containing the entire of file 2.
Maybe you need a literal string search, if you need exact matches:
$ grep -Ff file1.txt file2.txt > output
I thank you very much Alex, your command solved my problem.
when I extracted the columns, folowing command was pretty good: cut -f 1,2,3 File_name | sed 's/[\t]/,/g' > output