当前位置:   article > 正文

如何获取cURL以不显示进度栏?_curl 不显示进度

curl 不显示进度

本文翻译自: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有。


#1楼

参考:https://stackoom.com/question/UwFU/如何获取cURL以不显示进度栏


#2楼

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

#3楼

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 ,直接为我输出到终端。


#4楼

Some time ago wrote a simple script to do the scrapping for searching for example specific versions of jdk installed: 前段时间写了一个简单的脚本来抓取搜索安装的特定版本的jdk的示例:

  1. #!/bin/bash
  2. REPO_TAG_URL=$1
  3. SEARCH=`curl -s $REPO_TAG_URL`
  4. NEXT_PAGE=`echo $SEARCH | jq -r .next`
  5. echo $SEARCH | jq '.results[].name'
  6. while [[ $NEXT_PAGE != 'null' ]]; do
  7. SEARCH=`curl -s $NEXT_PAGE`
  8. NEXT_PAGE=`echo $SEARCH | jq -r .next`
  9. echo $SEARCH | jq '.results[].name'
  10. done
  11. 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/


#5楼

Not sure why it's doing that. 不知道为什么要这么做。 Try -s with the -o option to set the output file instead of > . 使用-o选项尝试-s来设置输出文件,而不是>


#6楼

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
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/198413
推荐阅读
相关标签
  

闽ICP备14008679号