How to get only the reply line of a ping test on Windows

后端 未结 7 1301
你的背包
你的背包 2021-02-04 12:01

Usually, when pinging a server IP address we have this in return:

Pinging  with 32 bytes of data:
Reply from  : bytes=32 time=151 TTL         


        
7条回答
  •  死守一世寂寞
    2021-02-04 12:22

    For some reason, I couldn't get the FIND pipe to work in a powershell 5.1 shell. Feeling like this was all overly complicated, I thought if only I could grep the Reply line? I then found the powershell equivalent! I just used select-string on the first line matching 'Reply' which gave me the one line output I was looking for. So this worked very simply and easy for me.

    ping -n 1  | select-string -pattern 'Reply'
    

提交回复
热议问题