递归tar压缩?

山姆

我想创建一个tar文件来压缩包含子文件夹的文件夹。我正在终端中尝试以下命令int:

tar -czf folder directorios.tar.gz

directorios.tar.gz将是结果

安德鲁46

尝试:

tar -czvf directorios.tar.gz folder

一些注意事项:

  1. 手册页中递归是默认值tar

    -c, --create
        Create a new archive.  Arguments supply the names of the files to be archived.
        Directories  are  archived  recursively,  unless  the --no-recursion option is
        given.
    

    尽管可以使用--no-recursion选项关闭...

  2. 您需要存档名称-f选项中,正确的顺序是:

    tar -c [-f ARCHIVE] [OPTIONS] [FILE...]
             ^^^^^^^^^^
    
  3. 对于更灵活的命令行(特别是如果您想使用gzip和tar以外的其他压缩实用程序),可以省略-z选项,而使用-a--auto-compressoption允许tar根据档案后缀自动确定要使用的压缩器

    -a, --auto-compress
        Use archive suffix to determine the compression program.
    

    公认的后缀(及其伴随的压缩应用程序)为:

    • .gz:gzip
    • .tgz:gzip
    • .taz:gzip
    • .z:压缩
    • .taZ:压缩
    • .bz2:bzip2
    • .tz2:bzip2
    • .tbz2:bzip2
    • .tbz:bzip2
    • .lz:lzip
    • .lzma:lzma
    • .tlz:lzma
    • .lzo:lzop
    • .xz:xz
    • .zst:zstd
    • .tzst:zstd

焦油很酷:)

参考:

  • 8.1.1创建和读取压缩档案有关使用自动压缩选项和tar的声音信息,以及使用更手动和灵活的选项实现相同目标的可能性...

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章