问题描述:

I would like to zip all files/dirs while excluding a few listed within the variable $excludes. However the following piece of code is not excluding those files. Please help! Thanks!

excludes='"dir1/*" "dir2/*" "dir3/*"'

zip -r zipfile * -x $excludes

网友答案:

This should work:

zip -r zipfile * -x dir1/* dir2/* dir3/*

Or even this should work:

excludes='dir1/* dir2/* dir3/*'
zip -r zipfile * -x "$excludes"
网友答案:

Have you tried escaping the asterisk with a backslash:

excludes='"dir1/\*"'
相关阅读:
Top