ZIP

ZIP的说明里说 -x exclude the following names -i include only the following names

但实际 zip -r a.zip abc -x /cache/* 这样是不起作用的,可以尝试下。

正确姿势:zip -r a.zip abc -x \cache\*,简单来说就是要用反斜杠。

TAR

习惯性打 tar -zcvf test.tar.gz test --exclude=1 --exclude=2

这样是无效的,打包目录必须放到最后(先排除,后指定目录的意思吧)

正确姿势:tar -zcvf test.tar.gz --exclude=1 --exclude=2 test