Created
May 3, 2011 18:41
-
-
Save ahk/953932 to your computer and use it in GitHub Desktop.
find and replace strings in glob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $@ and $* are the same without quotes, but with quotes | |
# $* is one quoted string containing all args, $@ is one quoted string | |
# for each arg. This handles spaces in filenames correctly. | |
FINDSTR=${1}; | |
REPSTR=${2}; | |
shift; | |
shift; | |
echo "replace ${FINDSTR} with ${REPSTR} in" "$@" | |
for FN in "$@" | |
do | |
ruby -p -i -e "gsub('${FINDSTR}', '${REPSTR}')" "${FN}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment