Skip to content

Instantly share code, notes, and snippets.

@stratigos
Created January 9, 2015 17:51
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 stratigos/7ba947f99d7c0a9027da to your computer and use it in GitHub Desktop.
Save stratigos/7ba947f99d7c0a9027da to your computer and use it in GitHub Desktop.
Bash Search Replace Text in Files in a Directory, SVN stat the Files, and PHP Lint each modified file.
#!/bin/bash
if [[ $# -ne 3 ]];
then
echo "USAGE: sh $0 {search_string} {replace_string} {dirname}"
exit 1
else
echo Searching for $1 and replacing with $2 in all files in directory $3 ...
ack -Q -l "$1" $3 | xargs sed -i 's/'"$1"'/'"$2"'/g'
echo checking 'SVN stat' of each modified file, and running a PHP lint on each...
echo ----------------------------------------------------------------------------
svn st $3 | awk '{print $2}' | xargs -L 1 php -l
echo ----------------------------------------------------------------------------
fi
echo done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment