Skip to content

Instantly share code, notes, and snippets.

@funroll
Created May 2, 2013 18:07
Show Gist options
  • Save funroll/5504098 to your computer and use it in GitHub Desktop.
Save funroll/5504098 to your computer and use it in GitHub Desktop.
Example of using sed to replace all matches in multiple files. Using OS X 10.7.5. http://stackoverflow.com/questions/10445934/change-multiple-files/10764000#comment23188250_10764000
$ cd /tmp
$ echo "foo bar baz foo foo quz" > test1
$ echo "bar bar foo bar baz foo quz foo foo" > test2
$ sed -i '.bak' 's/foo/replaced/g' test*
$ tail test1 test2
==> test1 <==
replaced bar baz replaced replaced quz
==> test2 <==
bar bar replaced bar baz replaced quz replaced replaced
$ which sed
/usr/bin/sed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment