For a bash script I want to determine whether my device has Wi-Fi. The easiest way for me would be ifconfig and some regex. So I want to check if my interface en0 has a valid IP or not.
ifconfig en0 | grep inet | cut -d: -f2 | awk '{ print $2}'
gives me the IP. If I dont have one it doesn't return anyhting since the grep
command returns nothing. How do I check for that in an if
for example?