Obtain patterns in one file from another using ack or awk or better way than grep?
- by Rock
Is there a way to obtain patterns in one file (a list of patterns) from another file using ack as the -f option in grep? I see there is an -f option in ack but it's different with the -f in grep.
Perhaps an example will give you a better idea. Suppose I have file1:
file1:
a
c
e
And file2:
file2:
a 1
b 2
c 3
d 4
e 5
And I want to obtain all the patterns in file1 from file2 to give:
a 1
c 3
e 5
Can ack do this? Otherwise, is there a better way to handle the job (such like awk or using hash) because I have millions of records in both files and really need an efficient way to complete? Thanks!