Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-24-2005, 10:11 AM   #1
Registered: Dec 2004
Location: Bosnia and Herzegowina
Distribution: Centos, FreeBSD
Posts: 49

Rep: Reputation: 15
tar question


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.

Old 11-24-2005, 10:19 AM   #2
Senior Member
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 14.2 and current, SlackwareARM current
Posts: 1,602

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

Rep: Reputation: 31

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

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

2) There is a command called date. if you run
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:
tar cvfz `date +%Y-%m-%d`-cpp.tar.gz cpp/
so you get a file named 2005-11-34-cpp.tar.gz.



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 02:48 AM
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 10:55 AM
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 11:02 AM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 06:30 AM
tar.gz question <---NOOOOOB QUESTION jairo Linux - Software 4 02-17-2003 05:28 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration