

InterviewSolution
Saved Bookmarks
1. |
Solve : Cleaning up the output of ping? |
Answer» <html><body><p>I need a batch file that takes the output of ping and strips out the summary info and blank <a href="https://interviewquestions.tuteehub.com/tag/lines-240113" style="font-weight:bold;" target="_blank" title="Click to know more about LINES">LINES</a>, leaving just the individual times captured in a file. For example, I want to turn this:<br/><br/>Pinging yahoo.com [69.147.125.65] with 32 bytes of data:<br/><br/>Reply from 69.147.125.65: bytes=32 time=100ms TTL=53<br/>Reply from 69.147.125.65: bytes=32 time=101ms TTL=53<br/>Reply from 69.147.125.65: bytes=32 time=101ms TTL=53<br/>Reply from 69.147.125.65: bytes=32 time=101ms TTL=53<br/><br/>Ping statistics for 69.147.125.65:<br/> <a href="https://interviewquestions.tuteehub.com/tag/packets-770940" style="font-weight:bold;" target="_blank" title="Click to know more about PACKETS">PACKETS</a>: Sent = 4, Received = 4, Lost = 0 (0% loss),<br/>Approximate round trip times in milli-seconds:<br/> <a href="https://interviewquestions.tuteehub.com/tag/minimum-561095" style="font-weight:bold;" target="_blank" title="Click to know more about MINIMUM">MINIMUM</a> = 100ms, Maximum = 101ms, Average = 100ms<br/><br/>Into this:<br/><br/>Pinging yahoo.com [69.147.125.65] with 32 bytes of data:<br/>Reply from 69.147.125.65: bytes=32 time=100ms TTL=53<br/>Reply from 69.147.125.65: bytes=32 time=101ms TTL=53<br/>Reply from 69.147.125.65: bytes=32 time=101ms TTL=53<br/>Reply from 69.147.125.65: bytes=32 time=101ms TTL=53<br/><br/>Any ideas? Code: <a>[Select]</a> findstr /C:"Pinging" /C:"Reply" or using <a href="http://gnuwin32.sourceforge.net/packages/gawk.htm"> gawk for windows</a><br/> Code: <a>[Select]</a>C:\test&<a href="https://interviewquestions.tuteehub.com/tag/gt-249387" style="font-weight:bold;" target="_blank" title="Click to know more about GT">GT</a>;ping localhost | gawk "/Pinging/||/Reply/"<br/> Quote from: ghostdog74 on July 31, 2010, 11:52:47 PM</p><blockquote> Code: <a>[Select]</a> findstr /C:"Pinging" /C:"Reply" </blockquote> <br/>Thanks! The findstr method is perfect, since I don't want to rely on gawk being installed.</body></html> | |