-   Programming (
-   -   How to append today's date in a script (

anjaan 06-11-2004 02:30 PM

How to append today's date in a script
Hi all,

I am using a daily script which outputs a file. Test.html for example. How do I append a date to it so that the output will be TodaysDateTest.html for everyday.

Thanks very much

rkef 06-11-2004 02:34 PM

dosomething > `date +%F`_test.html

anjaan 06-11-2004 02:40 PM


Thanks :)

mparkhurs 06-12-2004 05:05 AM

I tried that, and for some reason it didn't work?

Maybe I did it wrong.

I personally like this:


ghost@sshd:~$ time=$(date | cut -b 5-10)
ghost@sshd:~$ echo "test" > "$time"_Test.html
ghost@sshd:~$ ls | grep Test
Jun\ 12_Test.html

rkef 06-12-2004 09:37 AM

mparkhurs, did you type it exactly as I had? If so, what was the output?

Spaces in filenames are generally Not a Good Thing, imo. Also, you've left the year off.

All times are GMT -5. The time now is 08:40 PM.