Explorar o código

calculate only numbers

Serghey Rodin %!s(int64=13) %!d(string=hai) anos
pai
achega
2cdeb72867
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      bin/v-update-web-domain-traff

+ 4 - 1
bin/v-update-web-domain-traff

@@ -45,9 +45,12 @@ bytes=0
 
 # Parsing log
 while read line; do
-    if [[ '-' != "$line" ]] && [[ 0 -lt "$line" ]]; then
+
+    if  [[ "$line" =~ ^[0-9]+$ ]]; then
+        line=${line#0}
         bytes=$(($bytes + $line))
     fi
+
 done < $log_file
 
 # Converting to Mb