Added from SO as off topic, however there is no answer in here

I want to zip a directory by excluding some unwanted subdirectories. I have tried :

zip -r test.zip * -x 'test1/' 'test2/'


zip -r test.zip * -x 'test1/' -x 'test2/'

But nothing happens.

1 Answer 1


Credits to Akhil (q.) and Naota (ans.)


zip -r test.zip * -x test1/\* test2/\*

The \* is an escaped wildcard character, which avoids path expansion by the shell prior to being passed to zip.

Reference (check --include explanation)

You must log in to answer this question.

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