Global Rename Ksh Scripts

These 2 files consisting of 10 lines of code allows you to rename a string within the whole file system. I’ve used this when creating new development environments and limited changes that pertain to only one set of directories. It keeps a record of changed files so you can double check that it doesnt do anything unexpected. It recreates the files,so permission might need to be changed back to the originals.
Note:
-$1 is the parameter search string to change
-*sh is the file filter criteria
-String1 is the string to change [same as $1 above]
-String2 is the desired new string name

f_find_it.sh
find . -name ‘*sh’ -exec grep -l “$1” {} \; > files.txt
ksh f_callsed.sh files.txt
ksh work1
rm work.1


f_callsed.sh
let x=1
while read -u3 f1; do
printf “sed -e ‘s/String1/String2/g’ $f1 > work.$x\n” >>work1
printf “cp work.$x $f1\n”>>work1
cat work1
done 3<$1



Subscribe for the latest posts, free promotions, and insider deals!!!