在一个命令中创建tar.xz [英] Create a tar.xz in one command
问题描述
我试图用一个命令创建一个.tar.xz
压缩档案.具体的语法是什么?
I am trying to create a .tar.xz
compressed archive in one command. What is the specific syntax for that?
我尝试过tar cf - file | xz file.tar.xz
,但这不起作用.
I have tried tar cf - file | xz file.tar.xz
, but that does not work.
推荐答案
对xz
使用-J
压缩选项.并记得 man tar
:)
Use the -J
compression option for xz
. And remember to man tar
:)
tar cfJ <archive.tar.xz> <files>
编辑2015-08-10:
Edit 2015-08-10:
如果您要将参数传递给带有破折号的tar
(例如:tar -cf
而不是tar cf
),则然后-f
选项必须排在最后,因为它指定了文件名(感谢 @ABB 指出!).在这种情况下,命令如下所示:
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>
这篇关于在一个命令中创建tar.xz的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!