Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.13 KB

tar_t.md

File metadata and controls

42 lines (30 loc) · 1.13 KB
layout title tags
manual
tar -t | List files before extracting
tar

Scenario

When we need to archive files or directories, we use command tar to do the work.

Option -t Command tar

tar stands for tap archives. -t is the abbreviation of list.

Manpage Description

List archive contents to stdout. The long option form is --list.

Detail Explain

It is possible that the size of a archived tar file is large and contains lots of files inside. With option -t, we don't need extract the tar file to find particular files.

We can use option -t to list the files inside first, and then use pipe to pass the results to another tool grep to see if particular files are inside this archived file.

This can help us to save time because the extraction might take a long time.

Version

Mac BSD General Commands Manual

Examples

Here is the example of tar -t.

  • tar -t List files inside the archive file.
$ tar -tf archived.tar 
tarFiles/
tarFiles/file3
tarFiles/file2
tarFiles/file1

$ tar -tf archived.tar|grep "file3"
tarFiles/file3