Both your strategies for checking the content of $output
would work if you just got the appropriate data into the variable. There are multiple ways to get command output into a variable. The following are all functionally equivalent.
output=`~/bin/foo | grep "\"<someID>\""` # deprecated -- use $(...) instead
output="$(~/bin/foo | grep "\"<someID>\"")" # may result in multiple lines of output
read -r output < <(~/bin/foo | grep "\"<someID>\"") # uses "Process Substitution"
The first two of these will work in any old POSIX shell. The first one even works in csh/tcsh. The last one, using Process Substitution, is bash-only (or at least, not POSIX).
But as you've seen in another answer, you probably don't need a variable. You can use a regex to match the whole line that you're interested in:
if ~/foo/bar | grep -q "\"$someID\""'": *"ENABLED"'; then
echo "enabled"
else
echo "disabled"
fi
This construct is safer if there's the possibility that $someID
might appear multiple times in your output, with different values.
If you use a case statement, then you'd want to make sure you know what to do if $someID
turns up multiple times.
while read -r output; do
case "$output" in
*ENABLED*) echo "enabled" ;;
*DISABLED) echo "disabled" ;;
*) echo "ERROR: Unknown state." >&2 ;;
esac
done < <(~/foo/bar | grep "\"$someID\"")