Decompress data.csv.bz2 to create data.csv.
Keep the original data.csv.bz2 file.
Which command is correct?
bunzip2 decompresses .bz2 data. The -k option keeps the compressed input after creating the decompressed file.
Detailed explanation
bzip2 -k data.csv.bz2Incorrect. bzip2 compresses input rather than decompressing it.
Incorrect. bzip2 compresses input rather than decompressing it.
bunzip2 -k data.csv.bz2Correct. bunzip2 -k creates data.csv and retains data.csv.bz2.
Correct. bunzip2 -k creates data.csv and retains data.csv.bz2.
gunzip -k data.csv.bz2Incorrect. gunzip is for gzip format, not bzip2.
Incorrect. gunzip is for gzip format, not bzip2.
unxz -k data.csv.bz2Incorrect. unxz is for xz format.
Incorrect. unxz is for xz format.
Try it yourself
An example you can run in a temporary verification environment.
LAB_DIR=$(mktemp -d)
printf demo > "$LAB_DIR/data.csv"
bzip2 "$LAB_DIR/data.csv"
bunzip2 -k "$LAB_DIR/data.csv.bz2"
test -f "$LAB_DIR/data.csv" -a -f "$LAB_DIR/data.csv.bz2" && echo BOTH
rm -r "$LAB_DIR"Expected result
BOTHKey points
- bunzip2 handles .bz2
- -k keeps the input
- Use the command for the matching format
Notes
- Environment: bzip2 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.