Skip to content

Instantly share code, notes, and snippets.

@wteuber
Last active October 26, 2016 20:40
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 wteuber/5345178 to your computer and use it in GitHub Desktop.
Save wteuber/5345178 to your computer and use it in GitHub Desktop.
batch in-place replacement off content visible files, excluding dot files
# grep -l -R -I --exclude "*.log" -e "old_stuff" . ## list files that contain old_stuff, excluding .log files
# grep -v '/\.' ## don't list dot files
# xargs sed -i "s/old_stuff/new_stuff/g" ## replace (and save) old_stuff with new_stuff in those files.
grep -l -R -I --exclude "*.log" -e "old_stuff" . | grep -v '/\.' | xargs sed -i "s/old_stuff/new_stuff/g"
@wteuber
Copy link
Author

wteuber commented Oct 26, 2016

OSX/zsh: grep -l -R -I --exclude "*.log" -e "old_stuff" . | grep -v '/.' | xargs sed -i "" "s/old_stuff/new_stuff/g"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment