I have two files named file1 and file2. I would like to delete the lines in file1 which are not in file2.
file1
rana 209 214 6 18 37 3 6.2
bashi 230 241 12 30 88 2.5 7.3
amir 245 250 6 14 29 2.3 4.8
joswa 190 195 6 15 45 2.5 7.5
edison 213 218 6 16 40 2.7 6.7
file2
bashi
edison
Desired output
bashi 230 241 12 30 88 2.5 7.3
edison 213 218 6 16 40 2.7 6.7
How can I do this with awk or sed?
awk
to do it, eventually,join -j 1 file1 file2
is a better choice for the purpose. – John C