stdin into zip command, how do I specify a file name?

吃可爱长大的小学妹 提交于 2019-12-22 03:06:11

问题


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 -

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


回答1:


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



回答2:


echo 'foo bar' | zip -@ /path/to/zipfile.zip should do it while keeping filename integrity



来源:https://stackoverflow.com/questions/29956087/stdin-into-zip-command-how-do-i-specify-a-file-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!