Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am new to the world of Linux and in the process of setting up a Linux environment. I stumbled across the tar command as I need to view the contents of a file prior to extracting it and by accident ran the command tar tvf as opposed to tar tvfz. Is there any difference in running either command apart from the the fact that the z option is for gzip files?

share|improve this question
add comment

2 Answers

As you are new to Linux then it seems appropriate to point you at the help system which is the man command.

As to your question it appears that tar is smart enough to realise that you have passed it a compressed archive and will process it appropriately even without the z switch.

tar -tvf suphp-0.7.1.tar.gz
drwxr-xr-x termi/termi       0 2009-03-14 18:08 suphp-0.7.1/
-rw-r--r-- termi/termi      13 2008-12-25 12:52 suphp-0.7.1/NEWS
-rw-r--r-- termi/termi    9416 2008-03-29 13:02 suphp-0.7.1/INSTAL
.
.
.

Note that if you use tvfz it will fail because a file has to follow the f switch

 tar -tvfz suphp-0.7.1.tar.gz
 tar: z: Cannot open: No such file or directory

so you should use tvzf

share|improve this answer
    
Iain - Thanks I did read the man pages however was unsure if running the inappropriate command would have repercussions –  PeanutsMonkey Jul 12 '11 at 20:23
    
@PeanutsMonkey: As you are running it in t test mode it's only reading the file anyway so won't damage it. –  Iain Jul 12 '11 at 20:32
    
Thanks. The article I am reading suggests that I run the command as tar tvfz - thegeekstuff.com/2010/04/unix-tar-command-examples –  PeanutsMonkey Jul 12 '11 at 20:42
    
@PeanutsMonkey: If that works with your tar then please let me know which verion it is. tar --version –  Iain Jul 12 '11 at 20:59
    
Iain - It is version 1.15.1. I am running the latest release of CentOS –  PeanutsMonkey Jul 12 '11 at 21:00
show 1 more comment

There is no difference other than tar tvf will not be able to read a .tar.gz file, only a .tar file.

share|improve this answer
    
Please see my comment to Ignacio Vazquez-Abrams –  PeanutsMonkey Jul 12 '11 at 20:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.