Appending date to UNIX Filenames

Hello,

I have a file name in the below format and have to append the date as _$currdate.

kchik_UK_lo.txt_$currdate.

The above should be the format and I dont want to put entire filename as above in the code, but it should give me the output as the above filename.Can anyone please help me out.

Thanks for all the help in advance

mv kchik_UK_lo.txt kchik_UK_lo.txt_$(date +%Y%m%d)

Thank you..
I dont want to put entire filename in the script(for ex: kchik* )how can I give the above filename using wildcard characters like *.please help.

for file in kchik*
do
        mv "$file" "${file}_$(date +%Y%m%d)"
done

Thanks a lot..:slight_smile:

---------- Post updated 07-22-13 at 01:06 AM ---------- Previous update was 07-21-13 at 11:52 PM ----------

One last help how can I send these filenames(only name of the files) in an email..?

Check mailx manual page or search this forum.

Instead of for loop can we use any other way for modiffying the filename

ls 'kchik*' xargs -i mv {} {}_$(date +%Y%m%d)
OR
find . -name 'kchik*' -type f | xargs -i mv {} {}_$(date +%Y%m%d)