Monday 28 April 2014

List the content of tar, tar.gz and tar.bz2 compressed files

tar is an archiving program designed to store and extract files from an archive file known as a tarfile. You can create a tar file or compressed tar file tar. However sometime you need to list the contents of a tar or tar.gz file on screen before extracting the all files. Following commands will help you to view the content of tarfile.



  • To list the content of tar file.

            # tar –tvf  file.tar


  • To list the content of a tar.gz file.

            # tar –ztvf  file.tar.gz



  •  To List the content of a tar.bz2 file.
# tar –jtvf file.tar.bz2

Where:

§  t: List the contents of an archive
§  v: Verbosely list files processed (display detailed information)
§  z: Filter the archive through gzip so that we can open compressed (decompress) .gz tar file
§  j: Filter archive through bzip2, use to decompress .bz2 files.
§  f filename: Use archive file called filename



No comments:

Post a Comment