Skip to content

Instantly share code, notes, and snippets.

@lukesh
Created September 15, 2009 15:30
Show Gist options
  • Save lukesh/187383 to your computer and use it in GitHub Desktop.
Save lukesh/187383 to your computer and use it in GitHub Desktop.
#!/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