Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I show the wget progress bar only? [closed]

Tags:

linux

bash

sh

wget

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.

like image 724
Flan Alflani Avatar asked Jan 13 '11 23:01

Flan Alflani


People also ask

How do I make wget silent?

You can use -nv or --no-verbose to make wget less verbose, but it won't show download progress in that case. Show activity on this post. --show-progress will override the "quiet" flag.

What is the difference between curl and wget?

The main difference between them is that curl will show the output in the console. On the other hand, wget will download it into a file.

What does the wget command do?

Wget is a networking command-line tool that lets you download files and interact with REST APIs. It supports the HTTP , HTTPS , FTP , and FTPS internet protocols. Wget can deal with unstable and slow network connections. In the event of a download failure, Wget keeps trying until the entire file has been retrieved.

What is the wget option?

Wget is the non-interactive network downloader which is used to download files from the server even when the user has not logged on to the system and it can work in the background without hindering the current process. GNU wget is a free utility for non-interactive download of files from the Web.


2 Answers

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

like image 139
Lord Bo Avatar answered Sep 20 '22 11:09

Lord Bo


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.

like image 23
Dennis Williamson Avatar answered Sep 17 '22 11:09

Dennis Williamson