LinuxQuestions.org
Review your favorite Linux distribution.
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
 
LinkBack Search this Thread
Old 07-08-2003, 09:04 PM   #1
x2000koh
Member
 
Registered: Jul 2002
Location: singapore
Distribution: red had 7.2
Posts: 109

Rep: Reputation: 15
how to add date to filename


Hi ! Linux user,
I am working on my tar archieve to create the table of content of tape drive. My command is as follow:

tar -tvf /dev/nst0 > mondaytape

The above is working fine. But I need to add a date so the file name 'mondaytape' will add the current date. So it become 'mondaytape-03July2003'

how can I do that. Appreciate if you can help.

regards,
x2000koh
 
Old 07-08-2003, 09:44 PM   #2
Cosmo92
LQ Newbie
 
Registered: Jul 2003
Posts: 3

Rep: Reputation: 0
You should be able to do something like this:

DATE=`date '+%d%m%y'`
tar -tvf /dev/nst0 > file_$DATE

If you read the man page on date you'll see the various formatting options
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
logrotate with date in filename ptp Linux - Newbie 1 04-14-2011 10:55 AM
How do I add the current date to a filename? sammysrefuge Linux - Newbie 2 03-18-2005 02:43 PM
put date as part of filename box_l Programming 3 07-27-2004 06:17 AM
Script add date to filename amphion Linux - Newbie 2 06-02-2004 07:12 AM
use date as output filename? wijnands Linux - Newbie 1 05-12-2004 03:39 PM


All times are GMT -5. The time now is 03:21 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration