I am trying to list the contents of a tar file. I see that by combining -t and -f I can do so. It seems to work even for compressed archives.

The combination of -z in addition with -tf also seems to give the same result. Does this mean that -z in this context has no effect or the effect is there but not observable.

I am a noob. So pardon mistakes if any in my question.

  • tar, ref. 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'.) – Knud Larsen Mar 5 '20 at 14:07
  • 1
    xkcd.com/1168 – marcellothearcane Mar 5 '20 at 16:45

You are correct that -tf and -tzf are the same for your file.

Modern versions of tar can automatically guess the type of compression of a compressed file. So, if it's a gzip file, it does not matter whether you specify the -z part or not.

For the same reason, you don't have to specify the j part in -tjf if it's a bzip2 compressed file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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