Skip to content

Instantly share code, notes, and snippets.

@goooooouwa
Created July 25, 2014 06:15
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 goooooouwa/0de4adddc0a0dd7a024d to your computer and use it in GitHub Desktop.
Save goooooouwa/0de4adddc0a0dd7a024d to your computer and use it in GitHub Desktop.
little bash script to replace all occurrences of the first command line argument in the given directories. It will display the diff and then ask to commit.
#!/bin/bash
eval 'find app/views app/controllers app/models -type f -exec sed -i "s/ $1[^s\"]/ ConstrBase::&/g" {} \;'
eval 'find app/views app/controllers app/models -type f -exec sed -i "s/ConstrBase:: $1/ConstrBase::$1/g" {} \;'
git diff
echo -n "Here be dragons. Continue?"
read REPLY
if [[ "$REPLY" =~ ^[Yy]$ ]]
then
git add .
eval "git cm 'fix: finish up all replacements of $1 with ConstrBase::$1'"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment