command line - Compare fields of two files - Ask Ubuntu


i have 2 files this:

file 1

apple fruit 10 4 strawberry fruit 22 11 berry fruit 33 33 ball toy 1 12 straw thing 2 33 

file 2

strawberry straw berry rawberry raw berry 

i want compare column 1 of file 2 column 1 of file 1, column 2 of file 2 column 1 of file 1, column 3 of file 2 column 1 of file 1. if match found, want display 3 matching lines file 1.

here, output should be:

strawberry fruit 22 11 straw thing 2 33 berry fruit 33 33 

how can using unix commands on terminal?

you can try grep -ff file2 file1

where, -f file2 reads patterns file2 , -f treats patterns fixed strings


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User