如何在bash中禁用'zip'警告?

Eng*_*uad 11 linux bash shell ubuntu zip

我想用bash shell压缩文件,所以我使用了:

echo -n 'Insert the file path:'
read path
echo 'Hello World' > ${path}
zip -u ${path}.zip ${path}
Run Code Online (Sandbox Code Playgroud)

当我运行这个脚本时,它会给我一个警告:

zip warning: test.zip not found or empty
adding: test (deflated 66%)
Run Code Online (Sandbox Code Playgroud)

它工作正常,但我如何禁用此警告?我zip是以正确的方式使用的吗?

Gaz*_*ler 33

我想你想要安静的旗帜.

zip -uq ${path}.zip ${path}
Run Code Online (Sandbox Code Playgroud)

从手册页:

-q
--quiet
          Quiet   mode;  eliminate  informational  messages  and  comment
          prompts.  (Useful, for example, in shell scripts and background
          tasks).
Run Code Online (Sandbox Code Playgroud)