content need changes- many files

Hi, all

Need some advise on this script

i have some files in a directory, and i need to change the word XX in each files to YY, how can i perform a bulk changes/

thanks in advance for yr sharing

Try

#! /bin/ksh
for i in *; do
sed 's/XX/YY/g' $i > $i.tmp
mv $i.tmp $i
done

That's completely true if you want to make those changes inside each file. If you want to chage just filemanes:

#! /bin/ksh
for f in *; do
new_name=$(echo $f | sed 's/XX/YY/')
mv "$f" "$new_name"
done

:slight_smile:
Regards.

using perl

perl -pi -e "s/XX/YY/g" *