Skip to content

Instantly share code, notes, and snippets.

@elliot-nelson
Last active December 28, 2015 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elliot-nelson/7450998 to your computer and use it in GitHub Desktop.
Save elliot-nelson/7450998 to your computer and use it in GitHub Desktop.
# Find foo's and replace with bar's, backing up as *.bak
grep -rl "foo" app/views | xargs sed -i .bak s/foo/bar/g
# Alternate: Require other patterns on the line
grep -rl "grok" app/views | xargs sed -i .bak -e '/grok/ s/foo/bar/g'
# Throw away the backup files
find . -name *.bak -print | xargs rm
# Another possibility, if all relevant files are part of the repo
git clean -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment