Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 328
Mehdi Avatar asked Apr 29 '15 22:04

Mehdi


People also ask

How do I zip a specific file?

To place multiple files into a zip folder, select all of the files while hitting the Ctrl button. Then, right-click on one of the files, move your cursor over the “Send to” option and select “Compressed (zipped) folder”.

How do I zip a file with a new name in Linux?

“rename zip file in linux” Code Answer To use mv to rename a file type mv , a space, the name of the file, a space, and the new name you wish the file to have.

How do I zip a file in command prompt?

If you open a terminal console in the parent directory, or used the cd command to navigate there from the command line, you should then be able to run the command on the folder. The syntax is ' zip -r <zip file name> <directory name> '. The '-r' option tells zip to include files/folders in sub-directories.

How do I zip multiple files in Shell?

In order to zip multiple files using the zip command, you can simply append all your filenames. Alternatively, you can use a wildcard if you are able to group your files by extension.


1 Answers

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 
like image 52
Hashbrown Avatar answered Oct 05 '22 22:10

Hashbrown