LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-20-2009, 12:29 AM   #1
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,461
Blog Entries: 6

Rep: Reputation: 51
LInux Script to add date to a filename?


I have a Backup script named shift.tar.gz created everyday under /repos/delta directory at 4:30 evening time. I want to save this as shift-10Jun2009.tar.gz under /repos/gamma/ directory automatically.what script I need to write?
 
Old 10-20-2009, 12:34 AM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 210Reputation: 210Reputation: 210
Add a line:
Code:
TARNAME=shift-`date "+%d%b%Y"`.tar.gz
Wherever your script reference shift.tar.gz, replace that phrase with $TARNAME

Last edited by jhwilliams; 10-20-2009 at 12:36 AM.
 
Old 10-20-2009, 12:36 AM   #3
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,461
Blog Entries: 6

Original Poster
Rep: Reputation: 51
That did the trick.
Thanks
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Date (day) to Filename greengrass Programming 1 01-15-2007 07:48 PM
Script to change date in filename minus one day ft77 Linux - General 3 06-02-2006 10:56 AM
How do I add the current date to a filename? sammysrefuge Linux - Newbie 2 03-18-2005 03:43 PM
Script add date to filename amphion Linux - Newbie 2 06-02-2004 08:12 AM
how to add date to filename x2000koh Programming 1 07-08-2003 10:44 PM


All times are GMT -5. The time now is 01:36 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration