Does sed issue an exit code?
Most versions of sed do not, but check the documentation that came with whichever version you are using. GNU sed issues an exit code of 0 if the program terminated normally, 1 if there were errors in the script, and 2 if there were errors during script execution. 5.9. The ‘r’ command isn’t inserting the file into the text. On most versions of sed (except HHsed and gsed-3.02), the ‘r’ (read) and ‘w’ (write) commands must be followed by exactly one space, then the filename, and then terminated by a newline. Any additional characters before or after the filename are interpreted as being part of the filename. Thus “/RE/r insert.me” would try to locate a file called ‘ insert.me’ (note the leading space!). If the file was not found, sed says nothing — not even an error message. When sed scripts are used on the command line, every ‘r’ and ‘w’ must be the last command in that part of the script. Thus, sed -e ‘/regex/{r insert.file;d;}’ source # will fail sed -e ‘/regex/{r insert.