LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 05-28-2010, 09:46 AM   #1
linuxuser2010
LQ Newbie
 
Registered: May 2010
Posts: 4

Rep: Reputation: 0
Need help scripting ..version control a file


So I'm not too familiar with scripting. I'm running a cron job to tar up a directory every night. However, I want to name each file based on the date. I know I'd have to script it so that it will have some sort of version control/date. Can someone assist in what I'd need to do to script that?
 
Old 05-28-2010, 09:52 AM   #2
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
ok, first answer was ignored... let's try again.

try this: file-`date +%Y%M%d`.tar

man date will help determine how to get the format you want.
 
Old 05-28-2010, 09:58 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Just one of many possibilities:

Code:
tar -xzvf filename_$(date +%F).tar.gz <files>
where <files> is replaced by the filename(s) to go in the archive.

Look at the man page for the date command to see other format possibilities
 
Old 05-28-2010, 10:00 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by eco View Post
ok, first answer was ignored... let's try again
??? (This is OP's first post.)
 
Old 05-28-2010, 10:09 AM   #5
linuxuser2010
LQ Newbie
 
Registered: May 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Thank you that did it!
 
Old 05-29-2010, 04:47 AM   #6
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
Quote:
Originally Posted by pixellany View Post
??? (This is OP's first post.)
Sorry for confusion.. I posted the answer once and it was ignored... nothing more.
 
Old 05-29-2010, 08:32 AM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
Quote:
Originally Posted by eco View Post
ok, first answer was ignored... let's try again.

try this: file-`date +%Y%M%d`.tar

man date will help determine how to get the format you want.
It's recommended to use $(command) instead of `command`. Backticks are very easily confused with single quotes and they are difficult to nest.
 
1 members found this post helpful.
  


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
version control icecubeflower Linux - Software 4 08-04-2009 04:10 AM
Samba version control Interflex Linux - Server 2 02-27-2009 07:56 AM
Version Control in Vi? bladehaze Linux - Software 1 10-08-2005 10:25 PM
X control scripting thatto Linux - Software 0 02-14-2005 04:07 AM


All times are GMT -5. The time now is 04:18 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration