A find and replace script

Hello everyone,
I am trying to do a simple script (shell or perl) for a bioinformatic problem, where I want to use a list from file2 and append this information to file1 (output).

Example:
File1

>Apple1 
GAGACGATTTATATATAGAAGAGAG
>Banana2 
CAGAGAGAGAGACCCCCCCCCCCC

File2

>Apple1      20     100
>Banana2    30     300

Ouput (new File1)

>Apple1   20     100
GAGACGATTTATATATAGAAGAGAG
>Banana2  30     300
CAGAGAGAGAGACCCCCCCCCCCC

If anyone has any feedback that would be greatly appreciated.

Cheers

herasj

Try:

awk 'NR==FNR{A[$1]=$0; next}$1 in A{$0=A[$1]}1' file2 file1
1 Like

Thanks, that helped!!!