LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   How to append today's date in a script (http://www.linuxquestions.org/questions/programming-9/how-to-append-todays-date-in-a-script-192391/)

anjaan 06-11-2004 01: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 01:34 PM

dosomething > `date +%F`_test.html

anjaan 06-11-2004 01:40 PM

Perfect

Thanks :)

mparkhurs 06-12-2004 04:05 AM

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

Maybe I did it wrong.

I personally like this:

Code:

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


rkef 06-12-2004 08: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 03:20 AM.