linuxfindzip

How can I create a zip file based upon a Linux find command?


I have the following command which will find every bin file recursively within a directory

sudo find . -type f -name "*.bin"

I want to create (in the current directory) a zip file names mybins.zip that will store the found bin files and preserve the directory structure.

Is this something zip can accomplish or is there another utility better suited to this task?


Solution

  • You can accomplish this with this command. This finds all the .bin files, then makes a zip containing every found one.

    sudo find . -type f -name "*.bin" | zip -r mybins.zip -@