LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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-19-2009, 11:29 PM   #1
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466
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-19-2009, 11:34 PM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
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-19-2009 at 11:36 PM.
 
Old 10-19-2009, 11:36 PM   #3
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466

Original Poster
Blog Entries: 6

Rep: Reputation: 51
That did the trick.
Thanks
 
  


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
Add Date (day) to Filename greengrass Programming 1 01-15-2007 06:48 PM
Script to change date in filename minus one day ft77 Linux - General 3 06-02-2006 09:56 AM
How do I add the current date to a filename? sammysrefuge Linux - Newbie 2 03-18-2005 02:43 PM
Script add date to filename amphion Linux - Newbie 2 06-02-2004 07:12 AM
how to add date to filename x2000koh Programming 1 07-08-2003 09:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:12 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