Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i search for files and zip them in one zip file

I tried to search files and zip them with the following commmand

find . regexpression -exec zip {} \;

however it is not working. How can i do this?

like image 346
LOGAN Avatar asked Nov 05 '12 15:11

LOGAN


People also ask

How do I combine multiple zip files into one?

Hold down [Ctrl] on your keyboard > Click on each file you wish to combine into a zipped file. Right-click and select "Send To" > Choose "Compressed (Zipped) Folder."

Can you zip a file within a Zip file?

Zipping zips is fine. If there is a problem, that would be a bug in the compression software :). You will probably not get any further compression for those files though unless you're using a higher level of compression. Zipping a zip can gain you more space even if the compression is the same.

Can you have zip folders within zip folders?

Notes: To add files or folders to a zipped folder you created earlier, drag them to the zipped folder. If you add encrypted files to a zipped folder, they'll be unencrypted when they're unzipped, which might result in unintentional disclosure of personal or sensitive information.

How do I sort files into a zip folder?

First you send the file you want at the top (mimetype) in the zip file to a compressed(zip) folder. Make sure it is only that file. Than I take the other files i want to zip (two folder in my case) mark them with the cursor and drag them up to the zip file i just created.


2 Answers

The command you use will run zip on each file separately, try this:

find . -name <name> -print | zip newZipFile.zip -@

The -@ tells zip to read files from the input. From man zip(1),

-@ file lists. If a file list is specified as -@ [Not on MacOS], zip takes the list of input files from standard input instead of from the command line.

like image 186
iabdalkader Avatar answered Nov 11 '22 06:11

iabdalkader


Your response is close, but this might work better:

find -regex 'regex' -exec zip filname.zip {} +

That will put all the matching files in one zip file called filename.zip. You don't have to worry about special characters in the filename (like a line break), which you would if you piped the results.

like image 36
Dan Jones Avatar answered Nov 11 '22 07:11

Dan Jones