From b6e23683ad4655cf58fd7f8b770b1eb5928f3088 Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Fri, 30 Jul 2010 17:24:22 +0300 Subject: [PATCH] ControlScripts: use $a + 0 in awk to extract numeric part from a string --- ControlScripts/parse_hrk.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ControlScripts/parse_hrk.sh b/ControlScripts/parse_hrk.sh index 694d37f..6a448e4 100755 --- a/ControlScripts/parse_hrk.sh +++ b/ControlScripts/parse_hrk.sh @@ -44,10 +44,8 @@ echo "time percent upspeed dlspeed" > $DATA_FILE # Clean and parse the log file grep '^ps' $LOG_FOLDER/$LOG_FILE | awk -F '[ \t<>:,]+' ' { - idx = match($10, "^[0-9]+"); - download = substr($10, idx, RLENGTH); - idx = match($14, "^[0-9]+"); - size = substr($14, idx, RLENGTH); + download = $10 + 0; + size = $14 + 0; percent = 100 * download / size; percent_string = sprintf("%.2f", percent); -- 2.20.1