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

标签 linux bash shell ubuntu zip

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

echo -n 'Insert the file path:'
read path
echo 'Hello World' > ${path}
zip -u ${path}.zip ${path}

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

zip warning: test.zip not found or empty
adding: test (deflated 66%)

它工作得很好,但我如何才能禁用此警告?我是否以正确的方式使用 zip

最佳答案

我想你想要安静的旗帜。

zip -uq ${path}.zip ${path}

来自手册页:

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

关于linux - 如何在 bash 中禁用 'zip' 警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7706311/

相关文章:

linux - 验证 tar.gz 没有损坏

c - 如何将十六进制字符串发送到串口?

linux - Bash - 查找 exec 返回值

linux - 终端被我的 .sh 字符编码吓坏了。我能做些什么?

linux - Bash- 在一行中从数组中求和值

linux - 谁阅读正则表达式、Shell 或命令?

linux - 使用 tr/sed 等在 Linux 上删除字符序列\r\n

bash awk 第一列和第三列之后的所有内容

python - 在不创建序列文件的情况下运行 BLAST (bl2seq)

linux - 运行 shell 脚本时出现 PAM 对话错误