Custom wget output

The below hides the messy commands of wget

#!/bin/bash

cd 'C:\Users\cmccabe\Desktop\wget'
wget -O getCSV.txt http://172.24.188.113/data/getCSV.csv
    progressfilt ()
{
    local flag=false c count cr=$'\r' nl=$'\n'
    while IFS='' read -d '' -rn 1 c
    do
        if $flag
        then
            printf '%c' "$c"
        else
            if [[ $c != $cr && $c != $nl ]]
            then
                count=0
            else
                ((count++))
                if ((count > 1))
                then
                    flag=true
                fi
            fi
        fi
    done
} 

output of the command:

--2015-04-30 14:12:45--  http://172.24.188.113/data/getCSV.csv
Connecting to 172.24.188.113:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/csv]
Saving to: 'getCSV.txt'

getCSV.txt              [ <=>                  ] 900.39K  --.-KB/s   in 0.03s

2015-04-30 14:12:48 (26.9 MB/s) - 'getCSV.txt' saved [921997]



What is the id of the NGS patient:

Is it possible to have:

Downloading file: 'getCSV.txt'

getCSV.txt              [ <=>                  ] 900.39K  --.-KB/s   in 0.03s

2015-04-30 14:12:48 (26.9 MB/s) - 'getCSV.txt' saved [921997]



What is the id of the NGS patient: 

Thank you :).

This is close with the text in bold missing (can they be added in the code):

 wget -O getCSV.txt http://xxx.xx.xxx.xxx/data/getCSV.csv --progress=bar:force 2>&1 | tail -f -n +6 
Downloading file:
getCSV.txt              [ <=>                  ] 900.39K  --.-KB/s   in 0.02s

2015-04-30 14:26:58 (37.7 MB/s) - 'getCSV.txt' saved in C:\Users\cmccabe\Desktop\wget



What is the id of the NGS patient: 

Filtering interactive things is always difficult. wget has something similar, however. Try wget -nv for less-verbose output which still has a progress bar -- much less messy.

Is it possible to do something like this:

#!/bin/bash

cd 'C:\Users\cmccabe\Desktop\wget'
wget -O getCSV.txt http://xxx.xx.xxx.xxx/data/getCSV.csv

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"
} 

Output on screen:

Downloading: getCSV.csv: % 

wget -q --no-progress url

Fiddle with --progress= to fine tune it, see man wget.

1 Like

Thank you :).

Er, typo. --show-progress, not --no-progress.

1 Like