archive.txt.xz is compressed in xz format.
Display the decompressed content on standard output without deleting the compressed file.
Which command is correct?
xzcat decompresses xz data to standard output. zcat is for gzip and bzcat is for bzip2.
Detailed explanation
zcat archive.txt.xzIncorrect. zcat is intended for gzip-compressed data.
Incorrect. zcat is intended for gzip-compressed data.
bzcat archive.txt.xzIncorrect. bzcat is intended for bzip2-compressed data.
Incorrect. bzcat is intended for bzip2-compressed data.
unxz archive.txt.xzIncorrect. unxz normally creates a decompressed file and removes the compressed input unless options change that behavior.
Incorrect. unxz normally creates a decompressed file and removes the compressed input unless options change that behavior.
xzcat archive.txt.xzCorrect. xzcat writes decompressed content to standard output and leaves the input file in place.
Correct. xzcat writes decompressed content to standard output and leaves the input file in place.
Try it yourself
An example you can run in a temporary verification environment.
printf 'kernelpath
' | xz | xzcatExpected result
kernelpathKey points
- xzcat handles xz
- zcat handles gzip
- bzcat handles bzip2
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.