即将curl
隐藏进度表我通过以下方式找到了很多答案堆栈交换分支确实提到-s
和-S
或只是-sS
在哪里
-s
隐藏进度条-S
仅显示错误消息,即使-s
使用时也是如此
因此建议工作为-sS
curl
在一些帖子中,提到了该选项的新添加--no-progress-meter
,例如:
我读man
--no-progress-meter
Option to switch off the progress meter output without muting or otherwise affecting warning and informational messages like --silent does.
Note that this is the negated option name documented. You can thus use --progress-meter to enable the progress meter again.
Example:
curl --no-progress-meter -o store https://example.com
See also -v, --verbose and -s, --silent. Added in 7.67.0.
和卷曲 ootw: – 沉默(由一位重要的curl提交者撰写)
但遗憾的是我不清楚如何--no-progress-meter
运作。乍一看,我认为这--no-progress-meter
相当于-sS
但是 - 这两个资源中都没有明确指出 - 因此我的假设是不正确的。
我确实做了一些实验:
没有错误
#1
curl https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz -O
# Shows
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 8472k 100 8472k 0 0 3500k 0 0:00:02 0:00:02 --:--:-- 3501k
#2
curl https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz -O -s
# Shows Nothing
#3
curl https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz -O -sS
# Shows Nothing
#4
curl https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz -O --no-progress-meter
# Shows Nothing
实际上并不清楚-sS
和之间的区别,--no-progress-meter
因为没有错误。
有错误
错误因为URL
不正确,它仅基于该https
部分
#1
curl https -O
# Shows
curl: Remote file name has no length!
curl: (23) Failed writing received data to disk/application
#2
curl https -O -s
# Shows nothing
#3
curl https -O -sS
# Shows
curl: (23) Failed writing received data to disk/application
#4
curl https -O --no-progress-meter
# Shows
curl: Remote file name has no length!
curl: (23) Failed writing received data to disk/application
观察#1
和#2
是一样的
问题
- 什么时候
-no-progress-meter
用完-sS
?
如果您能分享一些真实的例子来理解其中的区别,我们将不胜感激。
答案1
手册页说:
-s, --silent Silent or quiet mode. Don't show progress meter or error mes‐ sages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it. Use -S, --show-error in addition to this option to disable progress meter but still show error messages.
因此,本质上,有四种可能的组合,按安静程度递增的顺序排列:
没有选项:显示进度表、警告消息和错误消息
with
--no-progress-meter
:显示警告消息和错误消息,但不显示进度表。如果出现问题,此选项会提供信息,但如果没有问题,则不会显示任何信息。with
-sS
:仅显示错误消息,但不显示进度表或警告消息。如果您正在编写脚本并且知道某些情况可能会导致在特定情况下无害的警告消息,但仍然希望在发生意外情况时显示错误消息,那么这很好。with
-s
: 完全沉默,没有任何消息。