Being a noob, I can't comment, so posting a question to expand on the answers for this thread; How to test an Internet connection with bash?
for Mac users.
The -w1 or -w 1 option specified in the answers does not work on Mac However, -W1 or -W 1 does work. It is a case sensitivity issue for the Mac rather than an invalid/unavailable option.