I have a script with hundreds of lines and while my search and replace command works and removes it in multiple locations.
The text to replace is located in another file and my search and replace works perfectly but unfortunately I want only the first instance of the block text to be replaced.
ORIGINAL_FILE TEXT_FILE NEW_FILE
Replace all text between RECOMMENDED and STATIC with content from TEXT_FILE
sed -n -e "1,/RECOMMENDED/ p" -e "/STATIC/,$ p" -e "/RECOMMENDED/ r $TEXT_FILE" $ORIGINAL_FILE >$NEW_FILE
As I say this works but there are multiple locations where RECOMMENDED and STATIC are available and I want to only change the first instance.
Any help is greatly appreciated