1. Overview

wget is a Linux command for downloading data from the web. In this tutorial, we’re going to customize the wget output and show the progress bar only.

2. Using wget Options

Let’s start with downloading a page from a website:

$ wget https://www.baeldung.com
--2021-10-27 21:23:19--  https://www.baeldung.com/
Resolving www.baeldung.com (www.baeldung.com)... 104.26.12.74, 172.67.72.45, 104.26.13.74, ...
Connecting to www.baeldung.com (www.baeldung.com)|104.26.12.74|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length:  102117 (100K) [text/html]
Saving to: ‘index.html’

index.html          100%[===========================================================================>]  99.72K   352KB/s    in 0.3s

2021-10-27 21:23:20 (352 KB/s) - ‘index.html’ saved [102117/102117]

As we can see, the wget command prints a lot of information on the terminal.

2.1. Showing Progress Bar Only

In the case we want to get rid of all the output lines except for the progress bar, we can use the combination of –show-progress and -q options:

$ wget https://www.baeldung.com -q --show-progress
index.html          100%[===========================================================================>] 99.72K 231KB/s in 0.4s

The -q option turns off the wget output, and the –show-progress option forces wget to display the progress bar in any verbosity. Note that the –show-progress option is only available since GNU wget 1.16.

We can find the version of the installed wget in our system with –version option:

$ wget --version
GNU Wget 1.20.1 built on linux-gnueabihf

2.2. Changing Progress Indicator

With wget, the indicators for displaying the download progress are bar and dot. The bar indicator is used by default. But if the output is not a TTY, the dot indicator will be used by default.

We can set the progress type by –progress option:

$ wget https://www.baeldung.com -q --show-progress --progress=dot 
 0K .......... .......... .......... .......... .......... 50% 363K 0s
50K .......... .......... .......... .......... ......... 100% 751K=0.2s

Each dot represents a fixed amount of downloaded data.

3. Using grep

In the case of lower wget versions (< 1.16), in which the –show-progress option is not available, we can filter the lines we want to have a cleaner output. For example, in the wget output, we have a line with the ‘%‘ sign, which shows the downloading progress. We can find these lines with grep:

$ wget https://www.baeldung.com  2>&1 | grep '%'
 0K .......... .......... .......... .......... .......... 50% 339K 0s
50K .......... .......... .......... .......... ......... 100% 436K=0.3s

Notice that if we have a ‘%‘ sign in our URL, that line would also print to the terminal. In this case, we can search for another symbol like ‘=‘.

In this case, the dot symbol is used as the default indicator. So, if we want to use the bar parameter and override the dot indicator in any case, we can use the force parameter:

$ wget https://www.baeldung.com  2>&1 --progress=bar:force| grep '%' 
index.html    100%[===================>] 99.72K 259KB/s in 0.4s

Note that the force parameter is only available with the bar indicator.

4. Conclusion

In this article, we learned how to set only the progress bar and disable the other lines of wget output. In recent wget versions, we have –show-progress option to limit the output lines. For older versions, we may need to filter output lines with commands like grep to have a cleaner result.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.