Go2Linux | Linux Operating System

A site dedicated to: Linux Operating System

small tip - List the files in a tar, tar.gz, tar.bz2 files

Date: 2009-01-25 00:00:00 -0400

Today I needed to list some files in a .tar.gz files, and after checking the man page of the tar command, I decided to write this post for any one who may be asking. How to read the contents of a tar file?

Here is how.

tar -tf file.tar

This will list on the screen all files on the archive file.tar, you may want to use less, to page the output.

tar -tf file.tar | less

To list the files if the .tar file is gzipped.

tar -ztf file.tar.gz

or

tar -ztf file.tar.gz | less

To list the files if the .tar file is bzipped.

tar -jtf file.tar.bz2

or

tar -jtf file.tar.bz2 | less

You can also use grep to find a specific file in the archive.

If you liked this article please share it.

powered by TinyLetter

If you want to contact me in any other way, please use the contact page.