fix duration calculation to work across all platforms
diff --git a/scripts/monitor.sh b/scripts/monitor.sh
index 28cf935..24a5319 100755
--- a/scripts/monitor.sh
+++ b/scripts/monitor.sh
@@ -15,6 +15,7 @@
# This script sets up a watch with information that is valuable when
# developing voltha with k8s
+SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
CMD_KEY=cmd
if [ "$ARCH" == "Darwin" ]; then
@@ -23,5 +24,5 @@
kubectl get --all-namespaces pods,svc && echo "" \
&& kubectl describe --all-namespaces pods | grep Image: | grep voltha | sed -e "s/^ *//g" -e "s/: */: /g" && echo "" \
- && echo "DB SIZE: $(./scripts/etcd-db-size.sh)" && echo "" \
+ && echo "DB SIZE: $($SCRIPTPATH/etcd-db-size.sh)" && echo "" \
&& echo "RSS SIZE: $(ps -eo rss,pid,$CMD_KEY | grep /usr/local/bin/etcd | grep -v grep | cut -d\ -f1 | numfmt --to=iec | tr '\n' ' ' )"
diff --git a/voltha b/voltha
index af9dc0e..84abd2a 100755
--- a/voltha
+++ b/voltha
@@ -142,10 +142,10 @@
function parseDuration() {
local DUR=$1
local RESULT=0
- local TERMS=$(echo $DUR | sed -e 's/\([sSmMhHdD]\)/\1 /g' -e 's/,$//g')
+ local TERMS=$(echo $DUR | sed -Ee 's/([sSmMhHdD])/\1 /g' -e 's/,$//g')
for TERM in $TERMS; do
- local VALUE=$(echo $TERM | sed -e 's/\([0-9]\+\)[sSmMhHdD]/\1/')
- local UNIT=$(echo $TERM | sed -e 's/[0-9]\+\([sSmMhHdD]\)/\1/')
+ local VALUE=$(echo $TERM | sed -Ee 's/([0-9]+)[sSmMhHdD]/\1/')
+ local UNIT=$(echo $TERM | sed -Ee 's/[0-9]+([sSmMhHdD])/\1/')
case $UNIT in
s|S)
RESULT=$(($RESULT + $VALUE)) ;;