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?

3 Answers 3


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

Got it:

zip diffedfiles.zip $(cat diff-files.txt) -r
  • This will hit bash's max args thing if you have a really long list of files.
    – mlissner
    May 24, 2019 at 23:55

There are two methods that work on all platforms:


zip output.zip -r . -i@filelist.txt


zip -@ - < filelist.txt > output.zip

These methods are not affected by command-line length limits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.