Created
June 25, 2019 03:20
-
-
Save madsonic/669bec3ba87887bc726cfe9e6f7b89b6 to your computer and use it in GitHub Desktop.
search and replace file content
This file contains hidden or 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
| # mac | |
| sed 's/<target>/<replacement>/g' <inputfile> > <outputfile> | |
| # inplace | |
| sed -i '.bck' 's/<target>/<replacement>/g' <inputfile> | |
| # only if FOO appears in the line | |
| sed 'FOO/s/<target>/<replacement>/g' <inputfile> | |
| # multiple command | |
| sed -e 's/<target>/<replacement>/g' -e 's/<target>/<replacement>/g' <inputfile> | |
| # + delimiter | |
| sed 's+<target>+<replacement>+g' <inputfile> | |
| # s: search and replace | |
| # g: global | |
| # I: case insensitive | |
| # delimiter can be + instead of slash to avoide confusion with similar characters | |
| # -i : save file with given suffix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment