- 1 year ago
Create a tar.xz file on command line
Comment
1 / 1
To create a tar.xz
file on the command line, you can use the following command:
shelltar -cf - <source_directory> | xz -z -c - > <output_file.tar.xz>
Replace <source_directory>
with the directory you want to compress, and <output_file.tar.xz>
with the desired name and location of the resulting tar.xz
file.
Here's a breakdown of the command:
tar -cf - <source_directory>
creates a tar archive of the specified<source_directory>
. The-c
option creates a new archive, and the-f -
option directs the output to the standard output instead of a file.|
is the pipe operator, which redirects the output of thetar
command to the input of the next command.xz -z -c - > <output_file.tar.xz>
compresses the input data from the previoustar
command using the xz compression algorithm and saves it to the specified<output_file.tar.xz>
. The-z
option enables compression, and the-c -
option directs the output to the standard output instead of a file.
Note that the tar
and xz
utilities may need to be installed on your system for this command to work.