101-350 · Question #127
Which approach will provide a listing of the contents in a tar archive?
The correct answer is A. Use the tar command with -t. See the full explanation below for the reasoning.
Question
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
(49 responses)- A84% (41)
- B10% (5)
- D2% (1)
- E4% (2)
Community Discussion
4A is the one you card up. The -t flag (think "t for table of contents") tells tar to list archive contents without extracting anything, and it pairs with -f to specify the filename, so "tar -tf archive.tar" is the exact pattern to drill until it is automatic.
The only real distractor worth mentioning here is B, since some people try grepping a tarball and get garbage output, which at least teaches you something, but for an actual listing you need tar with the -t flag and that is the end of the story.
tar -t lists archive contents without extracting, that is the flag.
The only thing I would flag here is that test-takers sometimes second-guess A because they conflate -t with -x and start second-guessing themselves mid-exam, which is exactly the trap the question is setting. Read the stem again: listing, not extracting, so tar -t is the clean answer and nothing else on that list even gets close.