tar: list

1 
1 2.7 How to List Archives
1 ========================
1 
1 Frequently, you will find yourself wanting to determine exactly what a
1 particular archive contains.  You can use the '--list' ('-t') operation
1 to get the member names as they currently appear in the archive, as well
1 as various attributes of the files at the time they were archived.  For
1 example, assuming 'practice' is your working directory, you can examine
1 the archive 'collection.tar' that you created in the last section with
1 the command,
1 
1      $ tar --list --file=collection.tar
1 
1 The output of 'tar' would then be:
1 
1      blues
1      folk
1      jazz
1 
1 Be sure to use a '--file=ARCHIVE-NAME' ('-f ARCHIVE-NAME') option just
1 as with '--create' ('-c') to specify the name of the archive.
1 
1    You can specify one or more individual member names as arguments when
1 using 'list'.  In this case, 'tar' will only list the names of members
1 you identify.  For example, 'tar --list --file=collection.tar folk'
1 would only print 'folk':
1 
1      $ tar --list --file=collection.tar folk
1      folk
1 
1    If you use the '--verbose' ('-v') option with '--list', then 'tar'
1 will print out a listing reminiscent of 'ls -l', showing owner, file
11 size, and so forth.  This output is described in detail in ⇒verbose
 member listing.
1 
1    If you had used '--verbose' ('-v') mode, the example above would look
1 like:
1 
1      $ tar --list --verbose --file=collection.tar folk
1      -rw-r--r-- myself/user      62 1990-05-23 10:55 folk
1 
1    It is important to notice that the output of 'tar --list --verbose'
1 does not necessarily match that produced by 'tar --create --verbose'
1 while creating the archive.  It is because GNU 'tar', unless told
1 explicitly not to do so, removes some directory prefixes from file names
1 before storing them in the archive (⇒absolute, for more
1 information).  In other words, in verbose mode GNU 'tar' shows "file
1 names" when creating an archive and "member names" when listing it.
1 Consider this example, run from your home directory:
1 
1      $ tar --create --verbose --file practice.tar ~/practice
1      tar: Removing leading '/' from member names
1      /home/myself/practice/
1      /home/myself/practice/blues
1      /home/myself/practice/folk
1      /home/myself/practice/jazz
1      /home/myself/practice/collection.tar
1      $ tar --test --file practice.tar
1      home/myself/practice/
1      home/myself/practice/blues
1      home/myself/practice/folk
1      home/myself/practice/jazz
1      home/myself/practice/collection.tar
1 
1    This default behavior can sometimes be inconvenient.  You can force
1 GNU 'tar' show member names when creating archive by supplying
1 '--show-stored-names' option.
1 
1 '--show-stored-names'
1      Print member (as opposed to _file_) names when creating the
1      archive.
1 
1    With this option, both commands produce the same output:
1 
1      $ tar --create --verbose --show-stored-names \
1                 --file practice.tar ~/practice
1      tar: Removing leading '/' from member names
1      home/myself/practice/
1      home/myself/practice/blues
1      home/myself/practice/folk
1      home/myself/practice/jazz
1      home/myself/practice/collection.tar
1      $ tar --test --file practice.tar
1      home/myself/practice/
1      home/myself/practice/blues
1      home/myself/practice/folk
1      home/myself/practice/jazz
1      home/myself/practice/collection.tar
1 
1    Since 'tar' preserves file names, those you wish to list must be
1 specified as they appear in the archive (i.e., relative to the directory
1 from which the archive was created).  Continuing the example above:
1 
1      $ tar --list --file=practice.tar folk
1      tar: folk: Not found in archive
1      tar: Exiting with failure status due to previous errors
1 
1    the error message is produced because there is no member named
1 'folk', only one named 'home/myself/folk'.
1 
1    If you are not sure of the exact file name, use "globbing patterns",
1 for example:
1 
1      $ tar --list --file=practice.tar --wildcards '*/folk'
1      home/myself/practice/folk
1 
1 ⇒wildcards, for a detailed discussion of globbing patterns and
1 related 'tar' command line options.
1 

Menu