LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Non-*NIX Forums > General
User Name
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!


  Search this Thread
Old 03-26-2013, 08:15 AM   #1
LQ Newbie
Registered: Dec 2006
Posts: 28

Rep: Reputation: 0
tar extracts gzip file even without -z flag

Hi, i was creating tar archive with tar command and extracting it.

To create tar: tar -cvzf test.tar.gz /test
To extract: tar -xvf test.tar.gz

extract command was a mistake, i should have used -z option for gzip filter. but interestingly it works even without -z. i couldn't found any useful reference on Google why it works.

I have CentOS 6.2 linux.

Can you please help me understanding why tar extract work for gzip archive without using -z flag? Is it expected?
Old 03-26-2013, 08:29 AM   #2
Registered: Dec 2002
Location: Au
Distribution: Debian
Posts: 209

Rep: Reputation: 53
I guess the -a (--auto-compress use archive suffix to determine the compression program) option is a default, or maybe your site has TAR_OPTIONS set.
Old 03-26-2013, 08:57 AM   #3
LQ Veteran
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,678
Blog Entries: 1

Rep: Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102
Perhaps, this one:

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 and expect it to work!
Old 03-26-2013, 11:33 AM   #4
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,805

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
The '-a' option is in since tar-0.15, IIRC.


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
[SOLVED] tar + gzip/bzip2 with big file size limitation/solution limdel Linux - Newbie 3 03-24-2012 10:29 AM
tar file twice? put to tape? Gzip? jantman Linux - Software 4 03-25-2007 03:01 PM
invalid gzip magic (tar.gz file) hkhiroya Debian 2 05-23-2006 06:35 AM
How to unzip and untar a xxx.tar.gzip.part file> linuxharsha Linux - Software 8 02-15-2004 04:27 AM
How to untar and unzip .tar.gzip.part file? linuxharsha Linux - Software 2 02-14-2004 10:37 AM

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