LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-11-2004, 01:30 PM   #1
anjaan
LQ Newbie
 
Registered: Aug 2003
Posts: 19

Rep: Reputation: 0
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
 
Old 06-11-2004, 01:34 PM   #2
rkef
Member
 
Registered: Mar 2004
Location: bursa
Posts: 110

Rep: Reputation: 15
dosomething > `date +%F`_test.html
 
Old 06-11-2004, 01:40 PM   #3
anjaan
LQ Newbie
 
Registered: Aug 2003
Posts: 19

Original Poster
Rep: Reputation: 0
Perfect

Thanks
 
Old 06-12-2004, 04:05 AM   #4
mparkhurs
LQ Newbie
 
Registered: Jun 2004
Posts: 5

Rep: Reputation: 0
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:~$

Last edited by mparkhurs; 06-12-2004 at 04:18 AM.
 
Old 06-12-2004, 08:37 AM   #5
rkef
Member
 
Registered: Mar 2004
Location: bursa
Posts: 110

Rep: Reputation: 15
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Append the windows path with Samba login script ?? amitsharma_26 Linux - Networking 2 09-29-2005 10:46 AM
How to append hostname in a script anjaan Programming 5 06-14-2004 10:41 AM
help with Date command in script icw_sec Programming 6 01-06-2004 11:02 AM
Date in a BASH script... soulsniper Linux - Software 7 11-22-2003 06:08 PM
can't retrieve the date in my script wedgeworth Linux - Software 0 09-15-2003 11:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration