GNU sed, replace search string with contents of a file


Say, I want to replace the text “replace me” in all the .txt files in the current directory with the contents of modified.js file

find . -name "*.txt" -print0 | xargs -0 sed -i -e 's/replace me/cat modified.js/e'

Notice the ‘/e’ at the end and that seems to do the trick.

,

Leave a Reply

Your email address will not be published. Required fields are marked *