im looking to edit my 1.txt file, to find a word and replace it with the correspondant word in 2.txt and also add the rest of the string of file 2.

Im interest in maintain the order of my 1.txt file.

```
>title1
ID1 .... rest of string im not interested
>title2
ID2 .... rest of string im not interested
>title3
ID3 .... rest of string im not interested
>title....

```

But I want to add the information of my file 2

```
>ID1  text i want to extract
>ID2  text i want to extract
>ID3  text i want to extract
>IDs....

```

At the end im looking to create a new file with this structure

```
>title1
ID1 .... text I want
>title2
ID2 .... text I want
>title3
ID3 .... text I want
>title....

```

I have tried several sed commands, but most of them dont replace the ID# exactly for the one
that is in the two files. Hopefully it could be done in bash

Thanks for your help

Failed atempts..
my codes are
File 1 = cog\_anotations.txt, File 2=Real.cog.txt
ID= COG05764, COG 015668, etc...

```
sed -e '/COG/{r Real.cog.txt' -e 'd}' cog_anotations.txt
sed "s/^.*COG.*$/$(cat Real.cog.txt)/" cog_anotations.txt
sed -e '/\$COG\$/{r Real.cog.txt'  -e 'd}' cog_anotations.txt
grep -F -f cog_anotations.txt Real.cog.txt > newfile.txt
grep -F -f Real.cog.txt cog_anotations.txt > newfile.txt

```