Skip to content

Instantly share code, notes, and snippets.

@brownman
Created April 1, 2015 11:53
Show Gist options
  • Save brownman/385690319a71c2976e20 to your computer and use it in GitHub Desktop.
Save brownman/385690319a71c2976e20 to your computer and use it in GitHub Desktop.
rename package name: with/without capital letter
clear
replace2 ()
{
exclude_dir='.git';
old_string="$1";
new_string="$2";
path=$3;
cmd="grep --exclude-dir=$exclude_dir -rl '$old_string' $path | xargs sed -i s@$old_string@$new_string@g";
echo "$cmd";
echo 'execute?';
read answer;
if [ "$answer" = y ]; then
echo 'evaluating..';
eval "$cmd";
echo 'Results:';
grep --exclude-dir=$exclude_dir -R $new_string $path;
fi
}
#input: str_from str_to package_dir
replace2 Article Phone ./articles
replace2 article phone ./articles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment