I have two files on my Linux machine. The first "list.txt" contains a list of objects (2649 objects) while the second "list_interactors.txt" contains a shorter list with some of the objects in the previously list (719 objects) and for each of these there are in other columns some variables associated. I would like to obain a list of all the objects (2649) with the associated variable for the specific objects in file "list_interactors".
Example:
file list.txt
6tyr_A_002__________
7yer_2_009__________
3erf_1_001__________
2dr5_D_2-3__________
file list_interactors.txt
6tyr_A_002__________ 6tyr1_B QRT54R AAAAA
3erf_1_001__________ 3erf2_B QAEF6R XXXXX
output.txt
6tyr_A_002__________ 6tyr1_B QRT54R AAAAA
7yer_2_009__________
3erf_1_001__________ 3erf2_B QAEF6R XXXXX
2dr5_D_2-3__________
I'm not very pratical of the programming languages. I try to use the function grep with this script:
grep -f list.txt list_interactors.txt
but the output is a file like the file "list_interactors.txt".
Could you help me please?
join
, notgrep
. Check the man page – Francesco May 26 '20 at 08:37grep
you see is because the-f
option takes matching rules (=filtering rules) from the file. In the end, your command says "print all lines inlist_interactors.txt
that contain one of the strings inlist.txt
(which in your case is every line inlist_interactors.txt
). – AdminBee May 26 '20 at 09:13