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