Overview
unxz is part of the xz compression utility and is used to revert files with .xz or .lzma extensions to their original uncompressed form. By default, this command deletes the original compressed file after decompression.
Key Features
- Decompresses .xz and .lzma files
- Deletes original file (default behavior)
- Supports standard input/output
- Identical to xz -d command
Key Options
unxz is a symbolic link to the decompression mode of the xz command, so it uses the same options as xz -d.
Default Behavior and Output
Generated command:
Try combining the commands.
Description:
`unxz` Executes the command.
Combine the above options to virtually execute commands with AI.
Usage Examples
Various ways to decompress files using the unxz command.
Basic Decompression
unxz file.txt.xz
Decompresses file.txt.xz to create file.txt, and deletes the original file.txt.xz.
Decompress and Keep Original
unxz -k file.txt.xz
Uses the -k option to keep the original file.txt.xz after decompression.
Force Overwrite
unxz -f file.txt.xz
Forces overwriting the decompressed file (file.txt) using the -f option, even if it already exists.
Decompress Multiple .xz Files
unxz *.xz
Decompresses all .xz files in the current directory.
Decompress from Standard Input
cat archive.tar.xz | unxz | tar xf -
Decompresses a compressed tar archive using a pipe with the tar command.
Tips & Notes
Useful tips and points to note when using unxz.
Key Tips
- **Identical to xz -d**: unxz is a symbolic link to xz --decompress and functions exactly the same as xz -d.
- **Original File Deletion**: By default, the original .xz file is deleted after decompression. Use the `-k` or `--keep` option to preserve the original file.
- **Pipeline Usage**: unxz supports standard input/output, making it useful in pipelines. For example, you can use it like `cat file.xz | unxz > file`.
- **Error Handling**: If an error occurs during decompression, unxz returns a non-zero exit code. This can be utilized in scripts for error handling.