On Sat, Feb 16, 2002 at 11:20:32PM -0500, Steven T. Hatton wrote:
Saturday 16 February 2002 10:52 pm Landy Roman wrote:
trying to append todays day on a script to a file
i.e. i want cp /var/log/mail /var/log/mail.date????
I've done that in the past by piping date through sed and changing the characters in the date string to something filename friendly. I had to munge with the format of the data output. If you just want the date, try date -I. If you want the time in there as well, do a man on date. I found it kind of hard to understand at first. this will give you seconds, but you'll need to replace the ':'s using sed: date -Iseconds.
Try this: date -Iseconds | sed -e 's/:/-/g'
then maybe:
datasourc.sh > filename`date -Iseconds | sed -e 's/:/-/g'`
Why that complicated? It's all inside date command already: pike@fizia:~> date +%Y%m%d 20020216 So the original problem may be solved with a command like: cp /var/log/mail /var/log/mail.`date +%Y%m%d` If this construction is meant to be used in cronjob, please keep in mind that "%" character is used as a new line character in crontab and should be escaped. -Kastus