From 619b48f16404553d57dba87a01b67ffffc1aa8b8 Mon Sep 17 00:00:00 2001 From: John Gaunt Date: Thu, 27 Jan 2022 18:34:17 -0500 Subject: [PATCH] reverted brackets and fixed grep --- ubiquiti_stock.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ubiquiti_stock.sh b/ubiquiti_stock.sh index f26dad1..2c67efb 100644 --- a/ubiquiti_stock.sh +++ b/ubiquiti_stock.sh @@ -7,9 +7,9 @@ SOURCE_FILE='/tmp/source.html' wget -qO ${SOURCE_FILE} ${URL} -INVENTORY_QUANTITY=$(grep -o '"inventory_quantity":.,' ${SOURCE_FILE} | grep -o '[0-9]\+') +INVENTORY_QUANTITY=$(grep -o -m 1 '"inventory_quantity":[0-9]\+,' ${SOURCE_FILE} | grep -o '[0-9]\+') -if [ ${INVENTORY_QUANTITY} -gt 0 ]; then +if [[ ${INVENTORY_QUANTITY} -gt 0 ]]; then MESSAGE="There are currently ${INVENTORY_QUANTITY} in stock. ${URL}" echo ${MESSAGE} fi