尝试压缩不存在的文件时如何使 zip 命令行退出
How to make zip command line exit when trying to zip a file that doesn't exist
我正在尝试 zip
将多个文件合并到一个存档中。
例如在我的工作目录中有 2.txt
但没有 1.txt
:
$ zip -r 1.zip 1.txt 2.txt
zip warning: name not matched: 1.txt
adding: 2.txt (stored 0%)
$ echo $?
0
如果其中一个文件不存在,我有什么办法可以强制 zip
退出,而不是像现在这样只打印警告吗?
非常感谢
来自 zip(1)
手册页:
-MM
--must-match
All input patterns must match at least one file and all input
files found must be readable.
我正在尝试 zip
将多个文件合并到一个存档中。
例如在我的工作目录中有 2.txt
但没有 1.txt
:
$ zip -r 1.zip 1.txt 2.txt
zip warning: name not matched: 1.txt
adding: 2.txt (stored 0%)
$ echo $?
0
如果其中一个文件不存在,我有什么办法可以强制 zip
退出,而不是像现在这样只打印警告吗?
非常感谢
来自 zip(1)
手册页:
-MM --must-match All input patterns must match at least one file and all input files found must be readable.