如何只显示wget的进度条? [英] How to show wget progress bar only?
本文介绍了如何只显示wget的进度条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:
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
我知道卷曲能做到这一点,但是我需要得到wget来胜任这项工作。
I know curl can do that, however i need to get wget to do that job.
推荐答案
您可以使用下面的过滤器:
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 '%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
的序列正在发送的进度条开始前的权利。此行为可能是依赖于实现的。
This function depends on a sequence of 0x0d0x0a0x0d0x0a0x0d
being sent right before the progress bar is started. This behavior may be implementation dependent.
这篇关于如何只显示wget的进度条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文