1

I am trying to STDOUT the wget results to a text file and just wanted to get the last line of the progress bar in the results.

Here is the sample of my results.

--2018-02-01 11:16:45--  http://www.stackoverflow.com/
Resolving www.stackoverflow.com (www.stackoverflow.com)... 151.101.1.69, 151.101.65.69, 151.101.129.69, ...
Connecting to www.stackoverflow.com (www.stackoverflow.com)|151.101.1.69|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://stackoverflow.com/ [following]
--2018-02-01 11:16:45--  https://stackoverflow.com/
Resolving stackoverflow.com (stackoverflow.com)... 151.101.1.69, 151.101.65.69, 151.101.129.69, ...
Connecting to stackoverflow.com (stackoverflow.com)|151.101.1.69|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 254160 (248K) [text/html]
Saving to: ‘/dev/null’


/dev/null             0%[                    ]       0  --.-KB/s               
/dev/null            20%[===>                ]  50.27K   248KB/s               
/dev/null            75%[==============>     ] 186.90K   464KB/s               
/dev/null           100%[===================>] 248.20K   514KB/s    in 0.5s    

2018-02-01 11:16:46 (514 KB/s) - ‘/dev/null’ saved [254160/254160]

This is how I get it

wget -O /dev/null --progress=bar:force www.stackoverflow.com 2>> log_browse.txt

How do I output it in the file showing only this?

--2018-02-01 11:16:45--  http://www.stackoverflow.com/
Resolving www.stackoverflow.com (www.stackoverflow.com)... 151.101.1.69, 151.101.65.69, 151.101.129.69, ...
Connecting to www.stackoverflow.com (www.stackoverflow.com)|151.101.1.69|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://stackoverflow.com/ [following]
--2018-02-01 11:16:45--  https://stackoverflow.com/
Resolving stackoverflow.com (stackoverflow.com)... 151.101.1.69, 151.101.65.69, 151.101.129.69, ...
Connecting to stackoverflow.com (stackoverflow.com)|151.101.1.69|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 254160 (248K) [text/html]
Saving to: ‘/dev/null’


/dev/null           100%[===================>] 248.20K   514KB/s    in 0.5s    

2018-02-01 11:16:46 (514 KB/s) - ‘/dev/null’ saved [254160/254160]

Just the last line of the progress...

N.Omugs
  • 321
  • 4
  • 17

1 Answers1

0

You can use the tail command to read the file from the bottom.

wget -O /dev/null --progress=bar:force www.stackoverflow.com 2>> log_browse.txt
tail -n 1 log_browse.txt   

-n 1 --> Gets the last line. You can change that by changing the number EX: to get last two line use -n 2

Rakesh
  • 81,458
  • 17
  • 76
  • 113