Last active
August 29, 2015 14:01
-
-
Save mikedfunk/40155989ded3f60bf783 to your computer and use it in GitHub Desktop.
sed example
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
# search and replace with backup | |
# with -i it specifies a backup. So the file will be copied from myfile.txt to myfile.txt.bak before replacing any text. | |
# the * at the end is the filename. It can be myfile.* or *.txt or * or myfile.txt or whatever. | |
# mac version | |
sed -i .bak 's/hello/gbye/g' * | |
# linux version | |
sed -ibak 's/hello/gbye/g' * | |
# or just | |
sed 's/hello/gbye/g' * | |
# without backup | |
sed -i '' 's/hello/gbye/g' * | |
# specific file types | |
sed -i '' 's/hello/gbye/g' *.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment