1

This command prints the milliseconds till g.co ten times per second:

ping -i 0.1 g.co | grep ms

If I add just another grep it no longer prints anything ever (both on Mac and on Debian):

ping -i 0.1 g.co | grep ms | grep m

Why is that?

yes | grep y | grep y

This does print an infinite series of y lines as expected

NicuMarasoiu
  • 776
  • 9
  • 25

1 Answers1

0

Just wait for some time. mac os waits for the buffer to fill up before printing the whole block.

If you do want immediate line-by-line output, you can add the "--line-buffered" flags to both grep commands, effectively making your command -

ping -i 0.1 g.co | grep ms --line-buffered | grep m --line-buffered

For more details, refer to this other question - bash: force exec'd process to have unbuffered stdout

Prateek Paranjpe
  • 513
  • 3
  • 13