
The command then simply looks like this: tar caf file.tar.
#Tar xz create archive#
I can never remember which archive switch does what, so these days, I prefer the "auto-compress" feature in newer tar versions ( -a or -auto-compress). However, if you must, using those commands from the command line is fine. It uses GZIP and TAR combination to bind and compress data files. Best to have a habit of using -d or -decompress instead of unxz as well. TGZ is a UNIX based archive that uses GZIP compression technique to compress TGZ files. The docs recommend this in case you are using this for scripting. Note: unlike Rafael's answer, use xz -dc instead of catxz. To echo Rafael van Horn, to uncompress & untar (see note below): xz -dc | tar x z to manually set xz to zip, though it defaults to zipping if not otherwise directed. tar.xz, where VERSION is a number (for example, 8.0. I often use -k to -keep the original file and -9 for really heavy compression. MySQL compressed tar file binary distributions have names of the form mysql- VERSION - OS. Where -4e is, use your own compression options. > directs the tarred and compressed file to.xz -4e calls xz with the -4e compression option.f reads from a directory (best to put this second because -cf != -fc).c creates a new archive for the specified files.Tar cf - filename | xz -4e > īecause I liked Wojciech Adam Koszek's format, but not information: If you want to use compression options for xz, or if you are using tar on MacOS, you probably want to avoid the tar -cJf syntax.Īccording to man xz, the way to do this is: If you need to list the files only, use tar t. If you have only tar archive, you can use cat: cat archive.tar | tar x

Or tar c some-dir | bzip2 > 2ĭecompressing is also quite straightforward: xzcat | tar x It works with gzip and bzip2 too: tar c some-dir | gzip > It's also not necessary to specify the -z option for xz, because it's default. It's not necessary to put the f option in order to deal with files and then to use - to specify that the file is the standard input. Powered by and aspose. If you like the pipe mode, this is the most clean solution: tar c some-dir | xz > Create TAR.XZ file Compress files into TAR.XZ archive. You redirect the output from xz to the tar.xz file. XZ is configured to compress ( -z) the archive from standard input ( -). | pipes standard output to the input of another program. The output of this operation is generated on the standard output. Tar cf - directory reads directory/ and starts putting it to TAR format. From man tar: -J, -xz Filter the archive through xz (1). tar.xz archive tar cf - directory/ | xz -z - > Note that tar can do all this for you, theres no reason to first create a tar archive and then compress it, you can create it compressed: tar -cJvf archive.tar file 1-5.txt That will produce. In that case, the command looks like: tar -cJf

If you're passing the arguments to tar with dashes (ex: tar -cf as opposed to tar cf), then the -f option must come last, since it specifies the filename (thanks to for pointing that out!).
