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.
-$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
find . -name ‘*sh’ -exec grep -l “$1″ {} \; > files.txt
ksh files.txt
ksh work1
rm work.1
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[amazonify]::omakase::300:250[/amazonify]

Leave a Comment



Formatting Your Comment

The following XHTML tags are available for use:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

URLs are automatically converted to hyperlinks.