From: git Date: Sat, 16 May 2026 16:49:14 +0000 (-0400) Subject: countbytes: remove unnecessary escape characters X-Git-Url: https://git.datadissipation.net/?a=commitdiff_plain;h=4661018d1dc628ce4fcf2a06d9fa66f6af6c8c24;p=logtools.git countbytes: remove unnecessary escape characters --- diff --git a/countbytes b/countbytes index b6b7792..a0f3acb 100755 --- a/countbytes +++ b/countbytes @@ -12,4 +12,4 @@ err() { # there's no way for only one printf to fail [ -z "$SERVER" ] && SERVER=$(which > /dev/null 2>&1 apache2 && printf "apache2" || which > /dev/null 2>&1 nginx && printf "nginx" || err) -{ cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; gzip -cd $(ls /var/log/"$SERVER"/access.log.*.gz | sort -V); } | grep -a "$@" | awk 'match($0, /\" [0-9]{3} [0-9]+ \"/) { matchp = substr($0, RSTART, RLENGTH); split(matchp, nums, " "); n+=nums[3] } END { y=0; split("B K M G T", units); while (n >= 1024 && y < 4) { n /= 1024; y++; } if (y == 0) { print n } else if (n < 10) {printf "%.1f%c\n", n, units[y+1] } else { printf "%d%c\n", n, units[y+1]} }' +{ cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; gzip -cd $(ls /var/log/"$SERVER"/access.log.*.gz | sort -V); } | grep -a "$@" | awk 'match($0, /" [0-9]{3} [0-9]+ "/) { matchp = substr($0, RSTART, RLENGTH); split(matchp, nums, " "); n+=nums[3] } END { y=0; split("B K M G T", units); while (n >= 1024 && y < 4) { n /= 1024; y++; } if (y == 0) { print n } else if (n < 10) {printf "%.1f%c\n", n, units[y+1] } else { printf "%d%c\n", n, units[y+1]} }'