Create zip based on contents of a file list

compressionterminal

I created a file with diff files diff-files.txt it has 6000+ file paths in it. Now I want want to create a zip based on those files.

I know I can zip multiple files with:

zip diffedfiles.zip file1 folder1 -r

But that won't work with 6000+ files. Is there a way to zip it based on the content of diff-files.txt?

zip diffedfiles.zip {diff-files.txt} -r

Something like this?

Best Answer

On Linux you can use the -@ option:

-@ 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. For example,

          zip -@ foo

will store the files listed one per line on stdin in foo.zip.

So in your case you should be able to do:

cat diff-files.txt | zip -@ diffedfiles.zip
Related Topic