Linux – What happens if you use the command tar tvf as opposed to tar tvfz

linuxtar

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?

Best Answer

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