Created
February 15, 2012 23:33
-
-
Save jhbabon/1840048 to your computer and use it in GitHub Desktop.
Command line to substitute string patterns in a group of files
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
perl -e "s/old_pattern/new_pattern/g;" -pi.save $(ack -f path/to/files) | |
# NOTE: this will create *.save files. Remove them with: rm -f **/*.save |
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
ack -f path/to/files -print0 | xargs -0 sed -i -e 's/old_pattern/new_pattern/g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment