I have two files. The fist file is an existing C/C++ source file (
*.cpp). The second is a text file (
*.txt) and contains one function. The function is in both files, and it needs to be copied from the second file (
*.txt) to the first file (
*.cpp). The function is also rather long (890+ lines), so copy/paste is a bit unwieldy.
I have a
sed command to capture the function in the first file (
ifile=blake2.cpp.old ofile=blake2.cpp ffile=blake2-neon.txt sed -n '/^static void BLAKE2_NEON_Compress64(/,/^}$/p' < $ifile > $ofile
What I don't know is how to tell
sed to replace the text it has captured. I've tried to work through the GNU sed manual, but I'm not having much luck. One of the first things to do is drop the
How do I tell
sed to replace the block of text it finds with the text from another file?
I found a similar question at How to replace text between two markers in a file with a section of text from another file? but I don't quite follow whats going on, especially since the question is tagged
sed but the answers are provided for
The reason I am trying to script this is: its a port of IA-32 SSE to ARM NEON. I have a script that performs the basic substitutions. After a change, I need to copy the updated function to the source code, scp the code to a device, and then compile it. Lather, rinse, repeat. The manual copy/paste of a 1000 line function at each iteration consumes time better spent on other things.