赞
踩
本文翻译自:How do I get cURL to not show the progress bar?
I'm trying to use cURL in a script and get it to not show the progress bar. 我正在尝试在脚本中使用cURL,并使其不显示进度栏。
I've tried the -s
, -silent
, -S
, and -quiet
options, but none of them work. 我尝试了-s
, -silent
, -S
和-quiet
选项,但是它们都不起作用。
Here's a typical command I've tried: 这是我尝试过的典型命令:
curl -s http://google.com > temp.html
I only get the progress bar when pushing it to a file, so curl -s http://google.com
doesn't have a progress bar, but curl -s http://google.com > temp.html
does. 我只在将进度条推送到文件时才看到进度条,所以curl -s http://google.com
没有进度条,但是curl -s http://google.com > temp.html
有。
参考:https://stackoom.com/question/UwFU/如何获取cURL以不显示进度栏
I found that with curl 7.18.2 the download progress bar is not hidden with: 我发现使用curl 7.18.2时,下载进度条没有隐藏:
curl -s http://google.com > temp.html
but it is with: 但它具有:
curl -ss http://google.com > temp.html
In curl version 7.22.0 on Ubuntu and 7.24.0 on OSX the solution to not show progress but to show errors is to use both -s
( --silent
) and -S
( --show-error
) like so: 在Ubuntu的curl版本7.22.0和OSX的7.24.0版本中, 不显示进度但显示错误的解决方案是同时使用-s
(-- --silent
)和-S
(-- --show-error
),如下所示:
curl -sS http://google.com > temp.html
This works for both redirected output > /some/file
, piped output | less
这对于重定向输出> /some/file
,管道输出| less
| less
and outputting directly to the terminal for me. | less
,直接为我输出到终端。
Some time ago wrote a simple script to do the scrapping for searching for example specific versions of jdk installed: 前段时间写了一个简单的脚本来抓取搜索安装的特定版本的jdk的示例:
- #!/bin/bash
- REPO_TAG_URL=$1
-
- SEARCH=`curl -s $REPO_TAG_URL`
- NEXT_PAGE=`echo $SEARCH | jq -r .next`
-
- echo $SEARCH | jq '.results[].name'
-
- while [[ $NEXT_PAGE != 'null' ]]; do
- SEARCH=`curl -s $NEXT_PAGE`
- NEXT_PAGE=`echo $SEARCH | jq -r .next`
- echo $SEARCH | jq '.results[].name'
- done
-
- echo "Thats all folks"
You use it like this: ./script.sh https://registry.hub.docker.com/v2/repositories/library/tomcat/tags/
您可以这样使用它: ./script.sh https://registry.hub.docker.com/v2/repositories/library/tomcat/tags/
Not sure why it's doing that. 不知道为什么要这么做。 Try -s
with the -o
option to set the output file instead of >
. 使用-o
选项尝试-s
来设置输出文件,而不是>
。
curl -s http://google.com > temp.html
works for curl version 7.19.5 on Ubuntu 9.10 (no progress bar). 适用于Ubuntu 9.10上的curl版本7.19.5(无进度条)。 But if for some reason that does not work on your platform, you could always redirect stderr to /dev/null: 但是,如果由于某种原因在您的平台上不起作用,则可以始终将stderr重定向到/ dev / null:
curl http://google.com 2>/dev/null > temp.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。