Skip to content

Instantly share code, notes, and snippets.

@flavianmissi
Last active August 3, 2016 11:30
Show Gist options
  • Save flavianmissi/e29d199e90e68af07ad0 to your computer and use it in GitHub Desktop.
Save flavianmissi/e29d199e90e68af07ad0 to your computer and use it in GitHub Desktop.
find and replace with sed
find . -name *.py -type f -print0 -exec sed -i '' 's/pattern/new_pattern/g' {} +
# the above code seems to be bugged, instead:
for p in ` find . -name "*.html" -type f`;do sed -i '' 's/slug/tobase64/g' $p;done
# if you're not on OS X there is no need to pass -i '' to sed, just run:
find . -name *.py -type f -print0 -exec sed -i 's/pattern/new_pattern/g' {} +
# this avoids the "invalid command code ." error (on OS X)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment