Created
September 15, 2009 15:30
-
-
Save lukesh/187383 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
if [ "$#" -lt 3 ] | |
then | |
echo "Usage: $0 <filepattern> <searchterm> <replaceterm>" | |
echo "where <filepattern> is pattern of file to be scanned" | |
echo " <searchterm> is the pattern of the string to be found" | |
echo " <replaceterm> is the string that will replace <searchterm>" | |
exit 1 | |
fi | |
echo "Recursively replacing '$2' with '$3' in '$1' files..." | |
find . -iname "$1" -print0 | xargs -0 sed -i '.bak' "s^$2^$3^g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment