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

Mehdi picture Mehdi · Apr 30, 2015 · Viewed 11.7k times · Source

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?

Answer

Hashbrown picture Hashbrown · Feb 15, 2019

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