I am trying to filter the output of a running program (ping) and write the results to a file.
In the following example the ping program runs until CTRL-C is pressed:
ping www.google.com -t | findstr "Reply" >> file.txt
the result of this is the creation of 'file.txt' however, the contents are empty.
On the other hand, the following code, without piping to findstr works when interrupted with CTRL-C
ping www.google.com -t >> file.txt
What am I missing here?
Control the spelling of the findstr command is case sensitive you can use /I for disabled case sensitive and dot not use double quote
Parameter t does not allow redirection in a file because the pipe receive the result before do FINDSTR if using the n parameter file with the number of Reply wait the end of replay for see result file.
ping www.google.com -n 200 | findstr /I reply >> file.txt