List the contents of a tar.bz2

by on February 4, 2008 · 1 comment· last updated at December 4, 2008

Q. How do I list the contents of a tar.bz2 file under Linux or UNIX operating systems using a shell prompt?

A.bzip2 compresses most files more effectively than more traditional gzip or ZIP but is slower. In this manner it is fairly similar to other recent-generation compression algorithms. Unlike other formats such as RAR or ZIP (but similar to gzip), bzip2 is only a data compressor, not an archiver.

List the contents of a tar.bz2 file

To list the contents of a tar.bz2 file use GNU tar command as follows:
tar -jtvf {file-name.tar.bz2}
tar -jtvf file-name.tar.bz2 | less

If filename is backup.tar.bz2, enter:
$ tar -jtvf backup.tar.bz2
To search for a particular filename called data.txt, enter:
$ tar -jtvf backup.tar.bz2 | grep -i data.txt

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

GUI tools

Most modern GUI manager such as KDE or Gnome have inbuilt support for displaying and extracting tar.bz2 files.

GUI Archive Manager application

You can use the Archive Manager application to create, view, modify, or unpack an archive. An archive is a file that acts as a container for other files. An archive can contain many files, folders, and subfolders, usually in compressed form. Archive Manager provides only a graphical interface, and relies on command-line utilities such as tar, gzip, and bzip2 for archive operations.

Just double click on .tar.bz2 file to view its contents:

Fig.01: Linux / UNIX Archive Manager

Fig.01: Linux / UNIX Archive Manager


Archive Manager displays the archive contents in the main window as a file list with the following columns:

  1. Name: The name of a file or folder in the archive.
  2. Size: The size of the file when the file is extracted from the archive. For a folder, the Size field is blank. For information on how to display the size of the compressed file.
  3. Type: The type of the file. For a folder, the value in the Type field is Folder.
  4. Date modified: The date on which the file was last modified. For a folder, the Date modified field is blank.
  5. Location: The path to the file within the archive. This column is visible only when the window is in file view, when in folder view the location of the files is displayed in the Location text box of the folderbar.


You should follow me on twitter here or grab rss feed to keep track of new changes.

Featured Articles:

{ 1 comment… read it below or add one }

1 Harpreet March 4, 2009 at 9:39 am

Hi,
I need to calculate the size of each block contained in the bz2 file from the hex dump of the .bz2 file. This should be possible by going through first couple of lines of the hex dump.

regards
harpreet

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Tagged as: , , , , , , , , , , , , ,

Previous Faq:

Next Faq: