010-100 · Question #15
Which approach will provide a listing of the contents in a tar archive?
The correct answer is A. Use the tar command with -t. The tar command has a built-in option to list archive contents without extracting them. The -t flag (table of contents) performs this listing.
Question
Which approach will provide a listing of the contents in a tar archive?
Options
- AUse the tar command with -t.
- BUse the grep command.
- CUse the find command.
- DUse the zless command.
- EUse the zlist command.
How the community answered
(34 responses)- A79% (27)
- B3% (1)
- C12% (4)
- D6% (2)
Why each option
The tar command has a built-in option to list archive contents without extracting them. The -t flag (table of contents) performs this listing.
Running tar with the -t option (often combined with -f to specify the archive file, e.g., tar -tf archive.tar) reads the archive and prints each stored file path to standard output without extracting any data. This is the standard, correct method for inspecting tar archive contents.
The grep command searches text patterns within files or streams and cannot parse or list the internal structure of a tar archive.
The find command searches the live filesystem for files matching criteria and has no ability to inspect the contents of a tar archive.
The zless command is used to page through gzip-compressed text files and cannot list the file entries inside a tar archive.
There is no standard Linux command called zlist; this is not a valid utility.
Concept tested: Listing contents of a tar archive with -t
Source: https://man7.org/linux/man-pages/man1/tar.1.html
Topics
Community Discussion
No community discussion yet for this question.