How to Show the wget Progress Bar Only in Linux?


Abstract

Remote management of UNIX/Linux/BSD servers via an ssh session is a common practice. For installation, you might need to download the software or other files. For Linux operating systems, a few strong graphical download managers are available. However, the non-interactive downloader is preferred when using the wget command at the command line or shell prompt. The wget command supports a wide range of settings and Internet protocols, including HTTP, FTP, HTTPS, and others.

One of the simplest uses of the wget command is to download a single file and place it in the directory where you are currently working.

Linux Wget command

In order to download a file using wget, Type wget followed by the URL of the file you want to download. The file at the specified URL will be downloaded by wget and saved in the current directory. In the below example we will see how to use the wget command in Linux.

$ wget https://www.tutorialspoint.com/index.htm

Output

--2022-12-26 10:18:13--  https://www.tutorialspoint.com/index.htm

Resolving www.tutorialspoint.com (www.tutorialspoint.com)... 192.229.221.69
Connecting to www.tutorialspoint.com (www.tutorialspoint.com)|192.229.221.69|:443... connected.
HTTP request sent, awaiting response... 200 OKLength: 127735(125K)[text/html]

Saving to: index.htm'index.htm     

        
0%[                    ]       0  --.-KB/s               index.htm           100%[===================>] 124.74K  --.-KB/s    in 0.009s  2022-12-26 10:18:14 (12.9 MB/s) - 'index.htm' saved [127735/127735]$ 

Showing progress bar

When combined with the —show-progress option, the -q option in Wget enables you to display the download progress indicator while concealing all other output.

In the following example, we will se how to show the progress bar,

$ wget https://www.tutorialspoint.com/index.htm   -q --show-progressindex.htm

Output

0%[                    ]       0  --.-KB/s               index.htm           100%[===================>] 124.74K  --.-KB/s    in 0.03s   

Showing progress bar using grep

In order to filter the lines we wish to get a cleaner display for lesser wget versions ( 1.16), where the -show-progress option is not available. For instance, the line with the percentage sign (%) in the wget output indicates that the download is progressing.

In the following example we will see how to use grep for getting the progress bar,

$ wget https://www.tutorialspoint.com/index.htm   2>&1   |   grep '%'   

Output

0K .......... .......... .......... .......... .......... 40%  125M 0s
50K .......... .......... .......... .......... .......... 80% 6.45M 0s
100K .......... .......... ....                            100%  206M=0.008s

Conclusion

The GNU wget command is an effective command-line tool for downloading files, resuming interrupted partial downloads, mirroring HTTP/FTP sites, providing user authentication, throttling download speed, and many other tasks.

In this article, we learned how to disable the additional lines of wget output and set only the progress bar. We have the -show-progress option to restrict the output lines in more recent versions of wget. To get a better result with older versions, we might need to filter the output lines using tools like grep.

I hope these commands with the supporting examples will be beneficial in learning and exploring Linux.

Updated on: 23-Mar-2023

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements