Is it possible to grab the last line of wget? Is it possible to grab the last line of wget? unix unix

Is it possible to grab the last line of wget?


You can redirect the output of the command. For example:

$ wget --output-document=/dev/null http://website.com/file.jpg 2>&1 | tee /tmp/somefile$ tail -n 1 /tmp/somefile


If you have apache installed, you can use Apache HTTP server benchmarking tool:

ab -n1 http://website.com/file.jpg | grep -F 'Transfer rate:'

you get output like:

Transfer rate:          1722.38 [Kbytes/sec] received


wget -O /dev/null  http://website.com/file.jpg 2>&1 |sed -n '\%/dev/null%!d;s/.*(//;s/).*//p'

On my system, the final output line is empty, otherwise the sed addressing would be simpler. This is on Ubuntu out of the box; if your sed is different, you may need to adapt the script slightly.

(I tried with grep -o '(.*)' at first, but there is other text in parentheses earlier in the output from wget.)