extract the contents in between the tags

Friday, December 28, 2012 0 Comments


> cat file3
a
c
e
> cat file4
a 1
b 2
c 3
d 4
e 5
> awk 'FNR==NR{a[$0];next}($1 in a)' file3 file4
a 1
c 3
e 5
the above command says match the first field in file 4 with the first field in file3 and the print the line in file4 if a match is found.




0 comments: