将stdin转换为zip命令,如何指定文件名? [英] stdin into zip command, how do I specify a file name?

查看:44
本文介绍了将stdin转换为zip命令,如何指定文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我想使用zip压缩stdin的内容:

I want to compress the contents of stdin using zip, for instance:

echo 'foo bar' | zip  > file.zip

这可以正常工作,但是在解压缩时,未压缩的文件名为-

This works ok, but when unzipping, the uncompressed file name is -

我想知道如何为stdin指定文件名?

I was wondering how I could specify a file name for stdin?

推荐答案

您可以做的是正常地通过管道传输文件,然后重命名放在拉链中

What you can do is pipe the file in normally, then rename it in the zip

echo 'foo bar' | zip  > file.zip
printf "@ -\n@=filename.txt\n" | zipnote -w file.zip

这篇关于将stdin转换为zip命令,如何指定文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆