I have a folder which contains lot's of folders in it.

I don't need to zip all of them and I have a list of folders that need to be zipped in a separate file

The folder list is in the following format:

folder1 folder2 folder3...

Can I do something like this (this doesn't work, but I don't know how to pass arguments properly):

zip -r backup1.zip < listOfFolders.txt
  • I'm using windows and am connected via putty on my server and man pages aren't available
    – Jinx
    Jul 9, 2014 at 14:06

2 Answers 2


Use the option -@ to make zip read a list of files from its standard input.

$ cat listOfFolders.txt | zip -r@ part1.zip
  • The list of files must be one per line
    – Leon
    Nov 12, 2021 at 7:49
zip backup1.zip -r@ < listOfFolders.txt

Option r@ makes zip read inputs from stdin.

If you don't want to pass list of files from a temporary file listOfFolders.txt, We can use grep to filter files and pass results to zip as follows

grep -rl "<parent_folder_name>" <file/folder_name_regex> | zip backup1.zip -r@


As mentioned in the above answer like

listOfFolders zip -r@ backup1.zip

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.