Skip to content

Instantly share code, notes, and snippets.

@gregawoods
Created September 23, 2011 13:59
Show Gist options
  • Save gregawoods/1237406 to your computer and use it in GitHub Desktop.
Save gregawoods/1237406 to your computer and use it in GitHub Desktop.
Search a directory for PHP files and replace instances of split() with explode()
for file in $(egrep --include=*.php -rl "([^a-zA-Z_]+)split\(" .)
do
# you might replace 'preg_split' with 'explode' if you don't require regex support
sed -E "s/([^a-zA-Z_]+)split\(/\1preg_split\(/g" $file > /tmp/tempfile.tmp
mv /tmp/tempfile.tmp $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment