Skip to content

Instantly share code, notes, and snippets.

@johnbender
Last active December 13, 2015 23:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save johnbender/4990106 to your computer and use it in GitHub Desktop.
Replace a sed match with file contents.
replace=foo
replace_with=bar.txt
replace_in=baz.txt
sed -i.bkp "/$replace/{
s/$replace//g
r $replace_with
}" $replace_in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment