I have two file like:
1
2
3
4
5
6
7
8
9
10
and a file with two columns
1 0.11
2 0.12748
5 0.45
12 0.48
7 0.48
8 0.7
13 0.78
You can use grep -f patt_file file
to get the patterns from a file. That is, search in file
patterns included in patt_file
.
See the output with your given input:
$ grep -w -f file1 file2
1 0.11
2 0.12748
5 0.45
7 0.48
8 0.7
From man grep
:
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. If this option is used multiple times or is combined with the -e (--regexp) option, search for all patterns given. The empty file contains zero patterns, and therefore matches nothing.