I would like to replace the contents between $Elements$ and $EndElements$ in text file, f1, with the data from another file, f2.
The contents of f1 is given simply by
$Elements$
3
1
5
7
$EndElements$
And the contents of f2 is given as
1 65 71
2 32 87
3 39 98
4 41 63
What I would like to get at the end is:
$Elements$
1 65 71
2 32 87
3 39 98
4 41 63
$EndElements$
For this I tried some sed code from stackexchange pages(well I copied the code and do not have the window open anymore so I can not provide the direct link, sorry)
lead='^\$Elements\$$'
tail='^\$EndElements\$$'
# f2 is the file where the information
# to replace is kept in
sed -e "/$lead/,/$tail/{ /$lead/{p; r insert_file
> }; /$tail/p; d }" f2
which does not work, basically doing nothing.
$Elements$and$EndElements$the first and last lines in the first file?