Skip to content

Instantly share code, notes, and snippets.

@sflinter
Created January 20, 2011 22:53
Show Gist options
  • Save sflinter/788870 to your computer and use it in GitHub Desktop.
Save sflinter/788870 to your computer and use it in GitHub Desktop.
Perform an in-place (with backup) global search and replace on one or more files
# Perform an in-place (with backup) global search and replace on one or more files
$ ruby -i.bak -ple '$_.gsub!(/..../, "::::")' *
# Replace the ... with the regular expression that you're searching for,
# and the ::: with what you want to replace it with.
# Replace the file glob with whatever is appropriate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment