Skip to content

Instantly share code, notes, and snippets.

@jhbabon
Created February 15, 2012 23:33
Show Gist options
  • Save jhbabon/1840048 to your computer and use it in GitHub Desktop.
Save jhbabon/1840048 to your computer and use it in GitHub Desktop.
Command line to substitute string patterns in a group of files
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
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