Neo Gónzáles
Neo Gónzáles

Reputation: 231

How to make zip command line exit when trying to zip a file that doesn't exist

I'm trying to zip several file into one archive. e.g in my working directory there's 2.txt but no 1.txt:

$ zip -r 1.zip 1.txt 2.txt
zip warning: name not matched: 1.txt
adding: 2.txt (stored 0%)
$ echo $?
0

Is there any way for me to force zip to exit if one of the files doesn't exist, instead of just printing a warning like it currently does?

Thanks a lot in advance

Upvotes: 1

Views: 1481

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798566

From the zip(1) man page:

   -MM
   --must-match
          All input patterns must match at least one file  and  all  input
          files  found  must  be readable.

Upvotes: 3

Related Questions