I am writing a bash script to connect to a device via adb and then manipulate files. I prompt the user for an IP address to connect to, and then connect using adb connect $IP. However, I want to verify that the device was successfully connected, and abort the script if it was not.
I am thinking I would accomplish this with something like adb connect $IP | cat, and then check the output for the words "unable to connect" (I am fairly new to bash scripting, so this might be pretty basic). How would I write this in my script?