From: Razvan Deaconescu Date: Fri, 30 Jul 2010 14:24:22 +0000 (+0300) Subject: ControlScripts: use $a + 0 in awk to extract numeric part from a string X-Git-Tag: classic-scenario-config~20 X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=b6e23683ad4655cf58fd7f8b770b1eb5928f3088;p=p2p-testing-infrastructure.git ControlScripts: use $a + 0 in awk to extract numeric part from a string --- 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);