Am having difficulty checking if the contents of a variable contains a certain value or not e.g "Device_info"
The main code
if [ "${NUMBERRESULTS}" -eq 10 ]
then
echo "Success"
else
echo "Failed"
fi
The above query/script in addition to the variable initialisation produced 14 results when i run it (devices.sh) which was accurate but in this case I want to verify if the $NUMBERRESULTS variable or the result contains the device_info value or not. see below
Here is the code I am writing
if [[ $NUMBERRESULTS =~ .*device_info.* ]] - i tried using the =~ operator
then
echo "Success a device is present";
else
echo "Failed no device is present"
fi
See the values/fields i need to verify if they are present or not in the $NUMBERRESULTS variable results/contents.
"device_info": { i need to check if this field/value is present or not.
"connected_count": 36,
"current_config_id": 1618,
"default_config_id": 1618,
"first_connected": 1454576905,
"last_connected": 1454931872,
"registered": 1454576905,
"ip_address": "90.152.29.158",
"model_number": "GT-I9505",
"serial_number": "restful_api_device",
"mac_address": "00:00:00:00:00:00",
"smartcard": "unknown",
"hardware_version": "0",
"software_version": "83886336",
"manufacturer": "SAMSUNG"
thanks very much