Skip to content

Instantly share code, notes, and snippets.

@Folyd
Created September 6, 2015 08:16
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 Folyd/284319624e720fb6675f to your computer and use it in GitHub Desktop.
Save Folyd/284319624e720fb6675f to your computer and use it in GitHub Desktop.
Batch replace text in mac os
#!/usr/bin/env bash
old="onFailure(MetaCode"
new="onFailure(int"
# sed -i "s/$old/$new/g" `grep $old -rl $1`
# sed -i -e "s/$old/$new/g" `ls`
#The sed command is a bit different in Mac OS X, the ‘-i’ option
# required a parameter to tell what extension to add for the backup file.
#http://www.mkyong.com/mac/sed-command-hits-undefined-label-error-on-mac-os-x/
find $1 -name *.java | xargs sed -i '' "s/$old/$new/g"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment