mercredi 29 mars 2017

Grep pattern from file (list) into same line

i have to files (see below) and want to grep the patterns (file 1) from file 2(2 columns). I think it is reallys easy but i could not find any clue how to grep the matches to the same line

File1
ABC
DEF
GHI

File 2
ABC SeqX
ABC SeqY
ABC SeqP
DEF SeqW
DEF SeqO
GHI SeqR
GHI Seql

The output should look like this:

    ABC SeqX SeqY SeqP
    DEF SeqW SeqO
    GHI SeqR Seql

I know it has to be something like: grep -f file 1 file2 > output

I will be gratefu for any help.

Aucun commentaire:

Enregistrer un commentaire