gzip a file and append creation date stamp to file

I want to gzip a file and append the creation date to the end of the file. How can I accomplish this task. Basically they are log files which need a creation date stamp appended to make sure they do not overwrite other log files.

-jack

Assuming the file has not been modified since it was created then doing:

# ls -l file | awk '{ print "\n"$6" "$7 }' >> file

Will add the date and timestamp to the end of the file with a newline in front of it.

If after this you gzip the file then you can still view the contents of the file using either gzcat (link gzcat to gunzip if it does not yet exist) or use "gunzip -c", e.g.

# gunzip -c file.gz | tail -1

will show the last line which will be added date and time.

I believe the OP is really looking for something like:

zip archive-$(date +"%Y%m%d%H%M%S").zip someFile

jlliagre,

Thanks, I did not know zip worked that way. I tried with gzip however it does not work the same way as the zip command. What I am going to do is mv the file and have the date be appended then gzip all those files.

[code]
mv testfile testfile.`date +%Y-%m-%d`

[code]

My original intention was to have a file be gzip'd with the last modified date of the file appended to the file. I realized that mv does not alter the modified date of a file. Basically these are log files and I want to make sure someone behind me can debug an issue by knowing when the log file was last modified due to logging.

Thanks for your help, much appreciated,
-jack