i know this would be marked as a duplicate one, but i tried searching google and what i'm trying is not working for me.
I've some .txt
files in a directory, i need to rename all the *.txt
files to *_XYZ.txt
recursively. XYZ is defined in a variable X
.
I've tried below code:
file=`find ./ -type f -name "*.txt"|sed "s,^./,,g" |awk -F '.' '{print $1}'`
for i in "$file"
do
mv "$i" "$i_${X}.txt"
done
Any help would be greatly appreciated. Thanks.