List tar/tar.gz/tar.bz2 Contents – List all files in archive.tar
This is quick tip, howto list contents of tar, tar.gz and tar.bz2 files without unpacking file.
This is very useful on server environment where any graphical tool is not available. This method is also very useful when tar, tar.gz or tar.bz2 packages are really big, something like hundreds of megabytes or gigabytes (for example backups).
Overall, the key is the tar command with -t option.
List the Contents of tar File
List tar contents short command
tar -tvf archive.tar
List tar contents long command
tar --list --verbose --file=archive.tar
Parameters:
- -t, –list – list the contents of an archive
- -v, –verbose – verbosely list files processed
- -f, –file=ARCHIVE – use archive file or device ARCHIVE
Example output:
-rw-r--r-- foo/bar 7011 2010-10-01 01:19 pax/regtype1 -rw-r--r-- 1000/tarfile 7011 2010-10-01 01:19 pax/regtype2 -rw-r--r-- tarfile/tarfile 7011 2010-10-01 01:19 pax/regtype3 -rw-r--r-- tarfile/tarfile 7011 2010-10-01 01:19 pax/regtype4 -rw-r--r-- tarfile/tarfile 0 2010-10-01 01:19 misc/eof
List the Contents of tar.gz File
List tar.gz contents short command
tar -ztvf archive.tar.gz
List tar.gz contents long command
tar --gzip --list --verbose --file=archive.tar
Parameters:
- -z, –gzip – filter the archive through gzip
- -t, –list – list the contents of an archive
- -v, –verbose – verbosely list files processed
- -f, –file=ARCHIVE – use archive file or device ARCHIVE
Example output:
drwxr-xr-x tarfile/tarfile 0 2003-01-06 01:19 ustar/dirtype/ drwxr-xr-x tarfile/tarfile 255 2003-01-06 01:19 ustar/dirtype-with-size/ hrw-r--r-- tarfile/tarfile 0 2003-01-06 01:19 ustar/lnktype link to ustar/regtype lrwxrwxrwx tarfile/tarfile 0 2003-01-06 01:19 ustar/symtype -> regtype brw-rw---- tarfile/tarfile 3,0 2003-01-06 01:19 ustar/blktype
List the Contents of tar.bz2 File
List tar.bz2 contents short command
tar -jtvf archive.tar.bz2
List tar.bz2 contents long command
tar --bzip2 --list --verbose --file=archive.tar
Parameters:
- -j, –bzip2 – filter the archive through bzip2
- -t, –list – list the contents of an archive
- -v, –verbose – verbosely list files processed
- -f, –file=ARCHIVE – use archive file or device ARCHIVE
Example output:
-rw-r--r-- tarfile/tarfile 86016 2003-01-06 01:19 gnu/sparse -rw-r--r-- 1000/100 7011 2003-01-06 01:19 misc/regtype-old-v7 -rw-r--r-- tarfile/tarfile 7011 2003-01-06 01:19 misc/regtype-hpux-signed-chksum -rw-r--r-- 1000/100 7011 2003-01-06 01:19 misc/regtype-old-v7-signed-chksum drwxr-xr-x 1000/100 0 2003-01-06 01:19 misc/dirtype-old-v7/ -rw-r--r-- tarfile/tarfile 7011 2003-01-06 01:19 misc/regtype-suntar -rw-r--r-- lars/users 7011 2003-01-06 01:19 misc/regtype-xstar
Related posts:
- Linux: Display / Show File Contents (tabs, line breaks, non-printing characters)
- Linux Encrypt Files/Decrypt Files – GPG Interactive/Non Interactive Modes
- Delete files permanently with shred command in Linux – Remove absolutely
- Linux locate command: Find Files and Directories Quickly and Efficiently
- Linux Tip: How to handle a files with a dash as first character from command line
This guide rulez!
Thanks a lot!