I want to use
grep to search pattern from one file in a second one.
My pattern file is something like:
K02217 K07448 KO8980
The file to search in is:
>aai:AARI_24510 proP; proline/betaine transporter; K03762 MFS transporter, MHS family, proline/betaine transporter >aai:AARI_26600 ferritin-like protein; K02217 ferritin [EC:220.127.116.11] >aai:AARI_28260 hypothetical protein >aai:AARI_29060 ABC drug resistance transporter, inner membrane subunit; K09686 antibiotic transport system permease protein >aai:AARI_29070 ABC drug resistance transporter, ATP-binding subunit (EC:3.6.3.-); K09687 antibiotic transport system ATP-binding protein >aai:AARI_29650 hypothetical protein >aai:AARI_32480 iron-siderophore ABC transporter ATP-binding subunit (EC:3.6.3.-); K02013 iron complex transport system ATP-binding protein [EC:18.104.22.168] >aai:AARI_33320 mrr; restriction system protein Mrr; K07448 restriction system protein
The command I tried is:
fgrep --file=pattern.txt file.txt >> output.txt
This prints the lines of file.txt where the pattern is found. I need it to print also a column with the pattern found. So something like:
K07448 mrr; restriction system protein Mrr; K07448 restriction system K02217 ferritin-like protein; K02217 ferritin [EC:22.214.171.124]
Anyone can suggest me how to do?