LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-24-2009, 07:02 AM   #1
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,680
Blog Entries: 29

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
options with tar -j -z are optional


Hi,

I tried to untar bz2 and gz files with

tar -xf x.tar.bz2
tar -xf y.tar.gz

on OpenSuse 11.2

Both worked properly without -j or -z options !
When i search the net, I saw that every document writer is bent on specifying the -j and -z options with the respective files !

does it improve the quality or performance coz. i didnt see any one doing a tar without these options ??

Last edited by TheIndependentAquarius; 12-24-2009 at 10:38 PM.
 
Old 12-24-2009, 08:29 AM   #2
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
That works for me on Fedora.

It must automatically detect the .bz2 of .gz extension, or maybe bz2 or gz's magic number. That's actually very convenient for me because I often get confused with those 'j' and 'z' flags.

And there is no way that performance is reduced, because a 'gz' file and a 'tar' file are completely unrelated formats.

Unlike the Windows .zip format leads you to think, compression and archiving are completely separate tasks.

It's just that bzip2 and gzip are only compression formats. That is, they just compress a single stream of bytes, and they do not have the functionality to store information about a directory tree in there.

tar is just an archiving format. It's only purpose is to turn a directory tree into a single file/stream of bytes, that can later be decoded back into a directory tree. It is not a compression algorithm.

You can actually sometimes see bzip2 or gzip being used without tar to compress a single file.
 
Old 12-24-2009, 08:45 AM   #3
raju.mopidevi
Senior Member
 
Registered: Jan 2009
Location: vijayawada, India
Distribution: openSUSE 11.2, Ubuntu 9.0.4
Posts: 1,155
Blog Entries: 12

Rep: Reputation: 92
Quote:
Originally Posted by anishakaul View Post
Hi,

Both worked properly without -j or -z options !
It doesn't matter that whether you place option to compress/uncompress using specified options.

The magic lies in the name of the file.

Tar automatically selects the compression format as gunzip or bunzip using the file name.



that is if you want to compress some files
Code:
$tar -cvf myfiles.tar.bz *.jpg
Here I didn't specified bunzip option ( i.e. tar -cjvf ....) but output was compressed with bunzip format.

similarly for gunzip
Code:
$tar -cvf myfiles.tar.gz *.jpg
compressed using gunzip format,eventhough I didn't specified gunzip option ( i.e. tar -czvf ...)


This hold for extracting also.
 
2 members found this post helpful.
Old 12-24-2009, 09:39 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,899

Rep: Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579
Since a few versions ago(1.16/1.18 ?), tar autodetects the compression type according to the filename.
 
1 members found this post helpful.
Old 12-24-2009, 09:40 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2020 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,370

Rep: Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596
The ' tar ' flags changed five years ago ...

From /usr/doc/tar-1.15.1/NEWS , slack 10.2
Quote:
version 1.15 - Sergey Poznyakoff, 2004-12-20

* Compressed archives are recognised automatically, it is no longer
necessary to specify -Z, -z, or -j options to read them. Thus, you can
now run `tar tf archive.tar.gz'.
So now you can just do : 'tar xvf <archive>' with tar.gz an tar.bz2 .

No more jxvf or zxvf is required . !
.....
 
1 members found this post helpful.
Old 12-24-2009, 11:15 AM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,899

Rep: Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579
I backported that functionality to tar-1.13 for use with pkgtools -along with the switches for supporting bzip2, lzma and xz.
 
1 members found this post helpful.
Old 12-24-2009, 01:01 PM   #7
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-17.3 with Cinnamon & KDE
Posts: 1,681
Blog Entries: 3

Rep: Reputation: 105Reputation: 105
Quote:
Originally Posted by gnashley View Post
...
src2pkg
...
I looked at your src2pkg links. It seems pretty interesting.
Sadly, I'm an *-buntu guy and not slackware. I might fetch your sources and see how much hackery is needed to create a DEB file ... no where is that box of round tuits?

Cheers,
~~~ *<;-}( )( )//
 
Old 12-24-2009, 03:03 PM   #8
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Funny that this gz/bz2 auto-detecting functionality doesn't seem to be mentioned in my man page for tar, even though my version of tar does have the functionality.
 
Old 12-24-2009, 10:32 PM   #9
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,680

Original Poster
Blog Entries: 29

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Thanks to all of u for throwing light on the subject !

Quote:
Originally Posted by knudfl
The ' tar ' flags changed five years ago ...

From /usr/doc/tar-1.15.1/NEWS , slack 10.2
Quote:
version 1.15 - Sergey Poznyakoff, 2004-12-20

* Compressed archives are recognised automatically, it is no longer
necessary to specify -Z, -z, or -j options to read them. Thus, you can
now run `tar tf archive.tar.gz'.
So now you can just do : 'tar xvf <archive>' with tar.gz an tar.bz2 .

No more jxvf or zxvf is required . !
.....
I tried to uncompress the bz2 and gz files without -j, -z options on openSuse 10.3, It didn't work, openSuse 10.3 was not released 5 years back but much later, it is surprising why tar doesn't work without these options on it !!

Last edited by TheIndependentAquarius; 12-24-2009 at 10:41 PM.
 
Old 12-25-2009, 02:50 AM   #10
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,899

Rep: Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579
MTK358, tar is a GNU program so it is documented with an info page. Any man-page you have for tar is leftover from 10 years ago, or added by your distro. That reminds me to check and make sure mine has been updated with the last changes I made.

SaintDanBert, just since the latest version released last week, src2pkg does support creating debs, rpms and other formats and is available as an installable package in all these format also.

You can get the debian package here:
http://distro.ibiblio.org/pub/linux/...2.0-16_all.deb

I'd be very glad to hear any feedback from you as it hasn't been tried on most other systems yet. Please email me directly if you have any problems, suggestions or comments: amigo AT ibiblio.org
Gilbert
 
1 members found this post helpful.
Old 12-25-2009, 08:41 AM   #11
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2020 CentOS6.10 CentOS7.7 + 50+ other Linux OS, for test only.
Posts: 17,370

Rep: Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596Reputation: 3596
Post # 9
Quote:
I tried to uncompress the bz2 and gz files without -j, -z options on openSuse 10.3,
It didn't work, openSuse 10.3 was not released 5 years back but much later,
it is surprising why tar doesn't work without these options on it !!
Suse 10.3 has tar-1.17 , no 'j' or 'z' flag needed, unless you changed 'tar'.
Code:
knudfl@linux:~/tmp/2test-tar> tar xvf test-tar+bz2-1.17.tar.bz2
1
2
3
knudfl@linux:~/tmp/2test-tar> tar xvf test-tar+gz-1.17.tar.gz
1
2
3
This test was made on Suse 10.3, I also used it yesterday : tar xvf !
.....

Last edited by knudfl; 12-25-2009 at 08:46 AM.
 
Old 12-25-2009, 11:44 AM   #12
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Quote:
Originally Posted by gnashley View Post
MTK358, tar is a GNU program so it is documented with an info page. Any man-page you have for tar is leftover from 10 years ago, or added by your distro.
What? GNU does not have man pages?

Isn't it easier to type "man tar" than navigate all those menus?

Worst of all, I never, ever saw a Linux tutorial or instructions using info pages! I hardly ever heard of them! How was I supposed to know that info even exists?

Last edited by MTK358; 12-25-2009 at 11:46 AM.
 
Old 12-25-2009, 01:58 PM   #13
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,899

Rep: Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579
'man info'?? No, sorry, it's true. Official GNU programs frown on having man-pages since they have the 'wonderful' in-house tool called 'texinfo'. Don't get me wrong -I am no proponent of it -hate it in fact. And after 10 years using Linux, I... well I still have not been able to figure out how to use info to get any info! The trouble is that some programs have no man-pages at all, so you are stuck with on-line help or convertors. I am building a new system from scratch, and what I am gonna do is use one of the usable replacements, like pinfo or some info2html solution.
 
Old 12-25-2009, 03:28 PM   #14
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Why did they invent info when there already was man?

And still, I've NEVER heard of info before, except just once on some obscure web page I happened to get on accidentally. How is the average user even supposed to know about it?

Last edited by MTK358; 12-25-2009 at 03:32 PM.
 
Old 12-25-2009, 09:28 PM   #15
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-17.3 with Cinnamon & KDE
Posts: 1,681
Blog Entries: 3

Rep: Reputation: 105Reputation: 105
Quote:
Originally Posted by gnashley View Post
'man info'?? No, sorry, it's true.
...
Years ago ... yes, we had computers back then ... I got a pretty bound, dead tree edition of the "AT&T Unix ..." documentation. I started reading and very little made sense. While shuffling pages I stumbled across text that explained
  • the books were printed copies of the official man pages
  • the pages were in alpha order within each section 'man (1)..." then 'man (2) ..." etc.

At that point I noticed that I was reading in the 'G' part of this book for an item titled "Getting Started."

Sometimes you just gotta know ... [lol]
~~~ 0;-Dan
 
  


Reply

Tags
tar


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tar options, hyphen? heyduke25 Linux - Software 6 08-05-2009 03:03 PM
I need grep options to search inside a .tar.gz file. ZAMO Linux - General 2 06-24-2008 11:55 PM
tar and bzip2 options calande Linux - Software 1 04-10-2007 01:22 PM
backup with tar: which options? Lotharster Linux - Newbie 1 06-08-2006 01:32 PM
tar options dennis_89 Linux - General 7 06-23-2004 12:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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