Skip to content

Instantly share code, notes, and snippets.

@crazy-max
Created June 3, 2013 00:42
Show Gist options
  • Save crazy-max/5695540 to your computer and use it in GitHub Desktop.
Save crazy-max/5695540 to your computer and use it in GitHub Desktop.
filter wget progress - to display the progress bar only
#! /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