Difference between tar -tf vs tar -tzf

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.

2

1 Answer

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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like