如何只显示wget进度条?(How to show wget progress bar only?)

编程入门 行业动态 更新时间:2024-10-23 10:24:45
如何只显示wget进度条?(How to show wget progress bar only?)

例如:

wget http://somesite.com/TheFile.jpeg

downloading: TheFile.tar.gz ... --09:30:42-- http://somesite.com/TheFile.jpeg => `/home/me/Downloads/TheFile.jpeg' Resolving somesite.co... xxx.xxx.xxx.xxx. Connecting to somesite.co|xxx.xxx.xxx.xxx|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1,614,820 (1.5M) [image/jpeg] 25% [======> ] 614,424 173.62K/s ETA 00:14

我怎么能让它看起来像这样

downloading: TheFile.jpeg ... 25% [======> ] 614,424 173.62K/s ETA 00:14

我知道curl可以做到这一点,但是我需要让wget做这个工作。

For example:

wget http://somesite.com/TheFile.jpeg

downloading: TheFile.tar.gz ... --09:30:42-- http://somesite.com/TheFile.jpeg => `/home/me/Downloads/TheFile.jpeg' Resolving somesite.co... xxx.xxx.xxx.xxx. Connecting to somesite.co|xxx.xxx.xxx.xxx|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1,614,820 (1.5M) [image/jpeg] 25% [======> ] 614,424 173.62K/s ETA 00:14

How can i get it to look like this

downloading: TheFile.jpeg ... 25% [======> ] 614,424 173.62K/s ETA 00:14

I know curl can do that, however i need to get wget to do that job.

最满意答案

您可以使用以下过滤器:

progressfilt () { local flag=false c count cr=$'\r' nl=$'\n' while IFS='' read -d '' -rn 1 c do if $flag then printf '%c' "$c" else if [[ $c != $cr && $c != $nl ]] then count=0 else ((count++)) if ((count > 1)) then flag=true fi fi fi done }

用法:

$ wget --progress=bar:force http://somesite.com/TheFile.jpeg 2>&1 | progressfilt 100%[======================================>] 15,790 48.8K/s in 0.3s 2011-01-13 22:09:59 (48.8 KB/s) - 'TheFile.jpeg' saved [15790/15790]

此功能取决于在进度条开始之前正在发送的0x0d0x0a0x0d0x0a0x0d序列。 这种行为可能取决于实现。

You can use the following filter:

progressfilt () { local flag=false c count cr=$'\r' nl=$'\n' while IFS='' read -d '' -rn 1 c do if $flag then printf '%s' "$c" else if [[ $c != $cr && $c != $nl ]] then count=0 else ((count++)) if ((count > 1)) then flag=true fi fi fi done }

Usage:

$ wget --progress=bar:force http://somesite.com/TheFile.jpeg 2>&1 | progressfilt 100%[======================================>] 15,790 48.8K/s in 0.3s 2011-01-13 22:09:59 (48.8 KB/s) - 'TheFile.jpeg' saved [15790/15790]

This function depends on a sequence of 0x0d0x0a0x0d0x0a0x0d being sent right before the progress bar is started. This behavior may be implementation dependent.

更多推荐

本文发布于:2023-07-14 20:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1107282.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:只显示   进度条   wget   bar   show

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!