4

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
1
  • 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

5

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

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

(or)

As mentioned in the above answer like

listOfFolders zip -r@ backup1.zip

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .