问题
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