Skip to content

Instantly share code, notes, and snippets.

@daqing
Created February 14, 2009 16:42
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 daqing/64412 to your computer and use it in GitHub Desktop.
Save daqing/64412 to your computer and use it in GitHub Desktop.
#! /bin/bash
# recursively searching current directory for "foo" in PHP files and replace it with "bar"
for i in `find . -depth -name "*.php" -exec grep -Hni "foo" | awk -F: '{print $1}'`; do
if [ -f "$i" ]; then
sed -i ".old" -e "s/foo/bar/g' "$i"
fi
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment