-
-
Save daveshah/35633c49390262f0b697e3c8b47ae399 to your computer and use it in GitHub Desktop.
Bulk search & replace with ag (the_silver_searcher)
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
# ag <https://github.com/ggreer/the_silver_searcher> | |
# usage: ag-replace.sh [search] [replace] | |
# caveats: will choke if either arguments contain a forward slash | |
# notes: will back up changed files to *.bak files | |
ag -l $1 | xargs perl -pi.bak -e "s/$1/$2/g" | |
# or if you prefer sed's regex syntax: | |
ag -l $1 | xargs sed -ri.bak -e "s/$1/$2/g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment