Skip to content

Instantly share code, notes, and snippets.

@marioluan
Last active August 12, 2016 20:49
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 marioluan/23e921c14dc559b6daa1440c1712ba95 to your computer and use it in GitHub Desktop.
Save marioluan/23e921c14dc559b6daa1440c1712ba95 to your computer and use it in GitHub Desktop.
Shell script which finds and replaces all occurrences of given characters in files from the current directory.
#!/bin/bash
current_name=$1
new_name=$2
files=`grep -irl $current_name`
num_files=`grep -irl $current_name | wc -l`
echo "found $num_files file(s) with import name $current_name"
for ffile in $files; do
sed -i 's@'"$current_name"'@'"$new_name"'@g' $ffile;
echo "renamed in file $ffile";
done
echo "finished renaming."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment