I want to download a large file in automatic script with 'wget', but the 'progress' generated by 'wget' is too verbose. For example:
wget --progress=dot:mega 'http://mysite/my_large_file'
For my file is over 1.5GByes, while the speed is very fast (>9MB/s), even setting the progress style to 'mega', the output is still too verbose:
0K ........ ........ ........ ........ ........ ........ 0% 2.03M 13m16s
3072K ........ ........ ........ ........ ........ ........ 0% 3.85M 10m7s
6144K ........ ........ ........ ........ ........ ........ 0% 3.85M 9m3s
9216K ........ ........ ........ ........ ........ ........ 0% 3.89M 8m30s
But I don't want to completed turn off the output of progress, for it lets me to know if there is any issue. Now I use 'sed' to remove the dots:
wget --progress=dot:mega 'http://mysite/my_large_file' 2>&1 | sed -r 's/^ *([0-9]+K)[. ]*([0-9]+%) +([0-9.]+[A-Z]) +(.*)$/<\1,\2,\3\/s,remain:\4>, /g'
The output looks much better:
<0K,0%,2.45M/s,remain:11m0s>,
<3072K,0%,9.13M/s,remain:6m58s>,
<6144K,0%,9.35M/s,remain:5m35s>,
<9216K,0%,9.37M/s,remain:4m54s>,
<12288K,0%,9.52M/s,remain:4m28s>,
<15360K,1%,9.42M/s,remain:4m11s>,
Now I want to even remove the 'new line' characters at the end of each line, so my automation framework won't discard anything. I tried 'td', 'awk', but all of them don't output instantly. That is, when I use 'sed', it outputs the lines while the download is ongoing, but when I use 'td' or 'awk', I waited for a long time but nothing is output. I guess it will output the whole document when the download is finished, which is useless.
So I wonder if there is a way to remove the 'new line' characters while output the stream instantly.
By the way, is there a way that make 'wget' progress output less verbose but not 'no verbose'. For example print every 10MB or 20MB per line, or, my favorite way, print the progress every, for example 10 seconds.
As suggested in the comments, here I put my desired output:
<0K,0%,2.45M/s,remain:11m0s>, <3072K,0%,9.13M/s,remain:6m58s>, <6144K,0%,9.35M/s,remain:5m35s>, <9216K,0%,9.37M/s,remain:4m54s>, <12288K,0%,9.52M/s,remain:4m28s>, <15360K,1%,9.42M/s,remain:4m11s>,
All the output in one line.