LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-24-2005, 11:11 AM   #1
adnanm
Member
 
Registered: Dec 2004
Location: Bosnia and Herzegowina
Distribution: Centos, FreeBSD
Posts: 49

Rep: Reputation: 15
tar question


hi,

I want to compress a folder so I use this command:

tar cvf cpp.tar.gz cpp/

and it commpress me that.

So what I want is that instead of having the tar file named cpp.tar.gz I would like to have it like like this: date&time_cpp.tar.gz where date&time represents the date and time of compressing.

regards,
Adnan
 
Old 11-24-2005, 11:19 AM   #2
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware 14.1 (32 and 64 bit)
Posts: 1,587

Rep: Reputation: 121Reputation: 121
Something like
Code:
tar cvf $(date +%Y-%m-%d--%H-%M)_cpp.tar.gz cpp/
? man date gives you more format options.
 
Old 11-24-2005, 11:21 AM   #3
enemorales
Member
 
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 31
Hi,

Well, two things:

1) tar cvf .... does not do compression. The extension .tar.gz is "meaninless". You have to run tar cvfz ... to make tar compress the data. Indeed, you can have better compression with

Code:
tar cvfj cpp.tar.bz2 cpp/
the problem is that it takes longer.

2) There is a command called date. if you run
Code:
date +%Y-%m-%d
(today it prints 2005-11-24)

should print the date with that format. Now it comes the tricky part. Use ` to make this output part of the name (sorry, don't know the name of that character, but notice it is ` and not '). This is done as this:
Code:
tar cvfz `date +%Y-%m-%d`-cpp.tar.gz cpp/
so you get a file named 2005-11-34-cpp.tar.gz.

HTH!
 
  


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
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 03:48 AM
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 11:55 AM
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 12:02 PM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 07:30 AM
tar.gz question <---NOOOOOB QUESTION jairo Linux - Software 4 02-17-2003 06:28 AM


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