I have a file Afile :
<start>
<memory>
<hdd>10</hdd>
<hdc>40</hdc>
</memory>
<storage>
<disk>
<disk1>firstname</disk1>
</disk>
<disk>
<disk1>secondname</disk1>
</disk>
<map>
<code>1</code>
</map>
<map>
<code>2</code>
</map>
</storage>
</start>
I have the second file Bfile:
<disk>
<disk1>thirdname</disk1>
</disk>
How using sed I can insert content of Bfile into Afile. So finally I need to have the following file:
<start>
<memory>
<hdd>10</hdd>
<hdc>40</hdc>
</memory>
<storage>
<disk>
<disk1>firstname</disk1>
</disk>
<disk>
<disk1>secondname</disk1>
</disk>
<disk>
<disk1>thirdname</disk1>
</disk>
<map>
<code>1</code>
</map>
<map>
<code>2</code>
</map>
</storage>
</start>
So it should be inserted after the last pattern. When I use the following command I get the following result:
sed -e '/disk>/rBfile' Afile
<start>
<memory>
<hdd>10</hdd>
<hdc>40</hdc>
</memory>
<storage>
<disk>
<disk1>firstname</disk1>
</disk>
<disk>
<disk1>thirdname</disk1>
</disk>
<disk>
<disk1>secondname</disk1>
</disk>
<disk>
<disk1>thirdname</disk1>
</disk>
<map>
<code>1</code>
</map>
<map>
<code>2</code>
</map>
</storage>
</start>
So it put the content of Bfile after each occurence of "disk>". I need just the last occurence. How to change the command?