developer tip

wget 진행률 표시 줄 만 표시하는 방법은 무엇입니까?

copycodes 2020. 11. 29. 11:53
반응형

wget 진행률 표시 줄 만 표시하는 방법은 무엇입니까?


예를 들면 :

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

어떻게 이렇게 보이게 할 수 있습니까?

downloading: TheFile.jpeg ...
25% [======>                              ] 614,424      173.62K/s    ETA 00:14

나는 컬이 그렇게 할 수 있다는 것을 알고 있지만, 그 일을하기 위해서는 wget이 필요합니다.


다음 필터를 사용할 수 있습니다.

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
}

용법:

$ 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]

이 기능은 0x0d0x0a0x0d0x0a0x0d진행률 표시 줄이 시작되기 직전에 전송 되는 순서에 따라 다릅니다 . 이 동작은 구현에 따라 달라질 수 있습니다.


사용하다:

wget http://somesite.com/TheFile.jpeg -q --show-progress

-q -Wget의 출력 끄기

--show-progress -wget이 진행률 표시 줄을 자세히 표시하도록 강제


이 옵션은 --show-progress, 다른 사람에 의해 지적 아웃로, 최선의 선택이지만, GNU wget을 단지부터 사용할 수 있습니다 1.16를 참조 wget을 1.16에서 주목할만한 변화를 .

안전을 위해 먼저 --show-progress지원 여부를 확인할 수 있습니다 .

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

wget $_PROGRESS_OPT ...

아마도 curl.


다음 follow옵션을 사용할 수 있습니다 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.


Use using these flags:

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

You can use standard options:

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

This is another exemple, maybe will help you

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

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

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).

참고URL : https://stackoverflow.com/questions/4686464/how-to-show-wget-progress-bar-only

반응형