Create a tar.xz in one command

前端 未结 5 1929
逝去的感伤
逝去的感伤 2021-01-29 18:32

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

5条回答
  •  孤独总比滥情好
    2021-01-29 19:12

    Switch -J only works on newer systems. The universal command is:

    To make .tar.xz archive

    tar cf - directory/ | xz -z - > directory.tar.xz
    

    Explanation

    1. tar cf - directory reads directory/ and starts putting it to TAR format. The output of this operation is generated on the standard output.

    2. | pipes standard output to the input of another program...

    3. ... which happens to be xz -z -. XZ is configured to compress (-z) the archive from standard input (-).

    4. You redirect the output from xz to the tar.xz file.

提交回复
热议问题