Created
January 9, 2015 17:51
-
-
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.
This file contains hidden or 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 [[ $# -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