List the members of backup.tar.
Do not extract files into the current directory.
Which tar command is appropriate?
tar -tf lists archive member names without extracting their contents.
Detailed explanation
tar -xf backup.tarIncorrect. -x extracts the archive.
Incorrect. -x extracts the archive.
tar -tf backup.tarCorrect. tar -tf backup.tar lists its members without extraction.
Correct. tar -tf backup.tar lists its members without extraction.
tar -cf backup.tarIncorrect. -c creates an archive and would overwrite or create output.
Incorrect. -c creates an archive and would overwrite or create output.
tar -rf backup.tarIncorrect. -r appends files to an archive.
Incorrect. -r appends files to an archive.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); printf x >"$tmp/item"; tar -cf "$tmp/backup.tar" -C "$tmp" item; mkdir "$tmp/view"; (cd "$tmp/view" && tar -tf ../backup.tar && test ! -e item); rm -rf "$tmp"Expected result
item(viewディレクトリには作成されない)Key points
- t lists
- x extracts
- f selects the archive file
Notes
- Environment: GNU tar 1.x / 一時ディレクトリ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.