I'm trying to run a command and interpret the results, but whatever I do I get a "command not found" error. Here's a representative version of my code:
devicename="emulator-5554"
search=$(adb devices | grep -w "$devicename" | grep -w device)
until $search; do
echo "Waiting..."
sleep 10
done
I've tried every variation that I can think of, including ...
search=$(adb devices | grep -w $devicename | grep -w device)
and
search=$(adb devices | grep -w ${devicename} | grep -w device)
..., but all return the same error.
How can I get the variable to be interpreted correctly?