bghosh
1
Hi All,
I have a requirement like, the source file is in the format :
XXXXXXXX.D0000.GZZZZ
I have to rename the file in the format :
XXXXXXXX.XXXXXXXX.D0000.GZZZZV00
I have to only rename the file if and only if the source file format has 3 parts as shown above.
ls -1 | while read filename
do
newName=$(echo $filename | awk -F"[.]" 'NF==3{print $1"."$1"."$2"."$3"V00"}');
[ -n "$newName" ] && mv $filename $newName
newName=""
done
bghosh
3
Hi Pravin,
Thanks for replying. COuld you please explain the code as I am new to Unix.