【问题标题】:Linux: Adding named files to a zip archive, from a pipeLinux:从管道将命名文件添加到 zip 存档
【发布时间】:2010-01-07 16:30:42
【问题描述】:

是否可以使用类似的东西:

command.exe | zip >> 存档.zip

command2.exe | zip >> 存档.zip

...最终在一个 zip 存档中包含两个命名文件。 这种方式,如果可能的话,会比临时文件更整洁。

【问题讨论】:

  • 在等待最后一个文本文件准备好时增加了峰值磁盘使用率。
  • 这不应该是服务器故障吗?

标签: linux compression zip


【解决方案1】:

在新目录中创建两个命名管道(使用 mkfifo),将命令的输出通过管道传输到这两个管道,然后压缩目录。

mkdir tmp
mkfifo tmp/1.out
mkfifo tmp/2.out
command1.exe > tmp/1.out
command2.exe > tmp/2.out
zip -FI -r tmp.zip tmp/

编辑:将 FI 标志添加到 zip,这确实使这成为可能。唯一需要注意的是,您需要 zip 3.0 才能工作。 Tar:ing FIFO:s 未实现(根据 tar devs),因为您需要提前确定文件大小才能将其写入 TAR 标头。

【讨论】:

    【解决方案2】:

    使用保险丝,fuze-zip

    【讨论】:

    猜你喜欢
    • 2011-09-07
    • 1970-01-01
    • 1970-01-01
    • 2011-09-15
    • 1970-01-01
    • 1970-01-01
    • 2014-04-15
    • 2020-07-10
    • 1970-01-01
    相关资源
    最近更新 更多