gpt4 book ai didi

linux - 从管道在命令行上创建 zip 时,如何在 zip 中指定文件名?

转载 作者:IT王子 更新时间:2023-10-29 00:15:55 28 4
gpt4 key购买 nike

我正在尝试从管道输入的文件内容创建一个 zip 文件,例如

mysql [params and query] | zip -q output.zip -

这会正确写入 zip,但是当您打开 zip 时,其中的文件名为“-”。有没有什么方法可以指定 zip 中传输数据的文件名?

最佳答案

你可以做到这一点。

ls | zip test.zip -@

这是根据我在目录中有 3 个文件的想法完成的。

-rw-rw-r-- 1 xxx domain users   6 Jan  7 11:41 test1.txt
-rw-rw-r-- 1 xxx domain users 6 Jan 7 11:41 test2.txt
-rw-rw-r-- 1 xxx domain users 6 Jan 7 11:41 test3.txt

和文件本身,结果就是

Archive:  test.zip
Length Date Time Name
-------- ---- ---- ----
6 01-07-10 11:41 test1.txt
6 01-07-10 11:41 test2.txt
6 01-07-10 11:41 test3.txt
-------- -------
18 3 files

来自 Linux Zip 手册页

If the file list is specified as -@, zip takes the list of input files from standard input.

关于linux - 从管道在命令行上创建 zip 时,如何在 zip 中指定文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2019603/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com