How can I show the wget progress bar only?

LinuxBashWgetSh

Linux Problem Overview


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 the following?

    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.

Linux Solutions


Solution 1 - Linux

Use:

wget http://somesite.com/TheFile.jpeg -q --show-progress
  • -q: Turn off wget's output

  • --show-progress: Force wget to display the progress bar no matter what its verbosity level is set to

Solution 2 - Linux

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.

Solution 3 - Linux

Run using these flags:

wget -q --show-progress --progress=bar:force 2>&1

Solution 4 - Linux

You can use the follow option of tail:

wget somesite.com/TheFile.jpeg --progress=bar:force 2>&1 | tail -f -n +6

The +6 is to delete the first 6 lines. It may be different on your version of wget or your language.

You need to use --progress=bar:force otherwise wget switches to the dot type.

The downside is that the refreshing is less frequent than with wget (looks like every 2 seconds). The --sleep-interval option of tail seems to be meant just for that, but it didn't change anything for me.

Solution 5 - Linux

The option --show-progress, as pointed out by others, is the best option, but it is available only since GNU wget 1.16, see Noteworthy changes in wget 1.16.

To be safe, we can first check if --show-progress is supported:

# set progress option accordingly
wget --help | grep -q '\--show-progress' && \
  _PROGRESS_OPT="-q --show-progress" || _PROGRESS_OPT=""

wget $_PROGRESS_OPT ...

Maybe it's time to consider just using curl.

Solution 6 - Linux

You can use standard options:

wget --progress=bar http://somesite.com/TheFile.jpeg

Solution 7 - Linux

This is another example:

download() {
    local url=$1
    echo -n "    "
    wget --progress=dot $url 2>&1 | grep --line-buffered "%" | sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}'
    echo -ne "\b\b\b\b"
    echo " DONE"
}

Solution 8 - Linux

Here is a solution that will show you a dot for each file (or line, for that matter). It is particularly useful if you are downloading with --recursive. This won't catch errors and may be slightly off if there are extra lines, but for general progress on a lot of files it is helpful:

wget -r -nv https://example.com/files/ | \
    awk -v "ORS=" '{ print "."; fflush(); } END { print "\n" }'

Solution 9 - Linux

This is not literally an answer but this snippet might also be helpful to some coming here for e.g. "zenity wget GUI":

LANG=C wget -O /dev/null --progress=bar:force:noscroll --limit-rate 5k http://nightly.altlinux.org/sisyphus/ChangeLog 2>&1 | stdbuf -i0 -o0 -e0 tr '>' '\n' | stdbuf -i0 -o0 -e0 sed -rn 's/^.*\<([0-9]+)%\[.*$/\1/p' | zenity --progress --auto-close

What was crucial for me is stdbuf(1).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFlan AlflaniView Question on Stackoverflow
Solution 1 - LinuxLord BoView Answer on Stackoverflow
Solution 2 - LinuxDennis WilliamsonView Answer on Stackoverflow
Solution 3 - LinuxAmir KhaliliView Answer on Stackoverflow
Solution 4 - LinuxMetaxalView Answer on Stackoverflow
Solution 5 - LinuxryenusView Answer on Stackoverflow
Solution 6 - LinuxslvaView Answer on Stackoverflow
Solution 7 - Linuxuser870774View Answer on Stackoverflow
Solution 8 - LinuxPhilipp KewischView Answer on Stackoverflow
Solution 9 - LinuxMichael ShigorinView Answer on Stackoverflow