While working with the archive files, sometimes you are required to list archive file contents instead of extract an archive file. Using this you can see the files available in an archive file. Read another tutorial with 18 Linux tar command examples
List Archive File Contents (Quick Commands)
The
tar -tvf archive.tar tar -ztvf archive.tar.gz tar -jtvf archive.tar.bz2 tar -Jtvf archive.tar.xz
List .tar File Content
Use
tar -tvf archive.tar
[Sample Output]
drwxr-xr-x root/root 0 2018-01-12 11:11 backup/ drwxr-xr-x root/root 0 2018-01-12 11:09 backup/data/ -rw-r----- root/root 1058 2018-01-12 11:09 backup/data/config.ini -rw-r--r-- root/root 29 2018-01-12 11:11 backup/.htaccess -rw-r----- root/root 442 2018-01-12 11:08 backup/access.log -rw-r--r-- root/root 7 2018-01-12 11:09 backup/index.html lrwxrwxrwx root/root 0 2018-01-12 11:11 backup/config -> data/config.ini
List .tar.gz File Content
We use
tar -ztvf archive.tar.gz
[Sample Output]
drwxr-xr-x root/root 0 2018-01-12 11:11 html/ drwxr-xr-x root/root 0 2018-01-12 11:09 html/config/ -rw-r----- root/root 1058 2018-01-12 11:09 html/config/config.ini -rw-r--r-- root/root 29 2018-01-12 11:11 html/.htaccess -rw-r----- root/root 442488 2018-01-12 11:08 html/access.log -rw-r----- root/root 263636 2018-01-12 11:08 html/error.log -rw-r--r-- root/root 17 2018-01-12 11:09 html/index.html lrwxrwxrwx root/root 0 2018-01-12 11:11 html/config.ini -> config/config.ini
List .tar.bz2 File Content
We use
tar -jtvf archive.tar.bz2
[Sample Output]
drwxr-xr-x root/root 0 2018-01-12 11:11 www/ drwxr-xr-x root/root 0 2018-01-12 11:09 www/data/ -rw-r----- root/root 1994 2018-01-10 10:19 www/data/config.ini -rw-r--r-- root/root 29 2018-01-12 11:11 www/.htaccess -rw-r----- root/root 33442 2018-01-11 10:08 www/index.php lrwxrwxrwx root/root 0 2018-01-12 11:11 www/config -> data/config.ini
List .tar.xz File Content
We use
tar -Jtvf archive.tar.xz
[Sample Output]
drwxr-xr-x root/root 0 2018-01-12 11:11 www/ drwxr-xr-x root/root 0 2018-01-12 11:09 www/data/ -rw-r----- root/root 1994 2018-01-10 10:19 www/data/config.ini -rw-r--r-- root/root 29 2018-01-12 11:11 www/.htaccess -rw-r----- root/root 33442 2018-01-11 10:08 www/index.php lrwxrwxrwx root/root 0 2018-01-12 11:11 www/config -> data/config.ini
1 Comment
Thanks… It’s helped me a lot …