Decompress archive.tar.xz to create archive.tar.
The compressed input does not need to remain after successful decompression.
Which command is appropriate?
unxz decompresses an xz file into its normal filename. Its default behavior removes the compressed input after successful extraction.
Detailed explanation
unxz archive.tar.xzCorrect. unxz creates archive.tar from archive.tar.xz.
Correct. unxz creates archive.tar from archive.tar.xz.
xz archive.tar.xzIncorrect. xz compresses input rather than decompressing it.
Incorrect. xz compresses input rather than decompressing it.
bunzip2 archive.tar.xzIncorrect. bunzip2 handles bzip2, not xz.
Incorrect. bunzip2 handles bzip2, not xz.
xzcat archive.tar.xz > archive.tar.xzIncorrect. It redirects output back to the compressed input and does not produce the requested file safely.
Incorrect. It redirects output back to the compressed input and does not produce the requested file safely.
Try it yourself
An example you can run in a temporary verification environment.
LAB_DIR=$(mktemp -d)
printf demo > "$LAB_DIR/archive.tar"
xz "$LAB_DIR/archive.tar"
unxz "$LAB_DIR/archive.tar.xz"
cat "$LAB_DIR/archive.tar"
rm -r "$LAB_DIR"Expected result
demoKey points
- unxz handles .xz
- The default removes compressed input
- xzcat writes decompressed data to standard output
Notes
- Environment: XZ Utils 5.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.