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

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.


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.


You can also provide the names as the result of your find command:

zip name.zip `find . -name <name> -print`

This is a feature of the shell you are using. You can search for "backticks" to determine how your shell handles this.