Created
May 2, 2013 18:07
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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