I am trying to create a .tar.xz
compressed archive in one command. What is the specific syntax for that?
I have tried tar cf - file | xz file.tar.xz
, but that does not work.
Use the -J
compression option for xz
. And remember to man tar
:)
tar cfJ <archive.tar.xz> <files>
Edit 2015-08-10:
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 @A-B-B for pointing that out!). In that case, the command looks like:
tar -cJf <archive.tar.xz> <files>