Created
June 3, 2013 00:42
-
-
Save crazy-max/5695540 to your computer and use it in GitHub Desktop.
filter wget progress - to display the progress bar only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
function wgetFilter() { | |
local flag=2 c count cr=$'\r' nl=$'\n' | |
while IFS='' read -d '' -rn 1 c | |
do | |
if [ $flag == 1 ] | |
then | |
printf '%c' "$c" | |
if [[ "$c" =~ (s$) ]] | |
then | |
flag=0 | |
echo "" | |
fi | |
elif [ $flag != 0 ] | |
then | |
if [[ $c != $cr && $c != $nl ]] | |
then | |
count=0 | |
else | |
((count++)) | |
if ((count > 1)) | |
then | |
flag=1 | |
fi | |
fi | |
fi | |
done | |
} | |
wget --progress=bar:force "http://www.foo.com.file" 2>&1 | wgetFilter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment