View Full Version : [ubuntu] ping in a bash script

February 13th, 2010, 05:51 PM

I would like to setup a ping test in one of my bash scripts. But *nix pings are continuous which would make the script continue until interrupted with Ctrl+C

How do you specify a certain number of pings to be issued?

ping -c $IPADDR

nm.. figured it out.. :)

February 13th, 2010, 06:21 PM
Yes, but you need an integer for the number of pings after the "-c" flag. For example, if you want to do three pings it would be:

ping -c 3 $IPADDR