#!/usr/app/TurboShell/bin/bash
# One line per day: how many lines of each level
set -euo pipefail
awk '
  NF > 2 { count[$1, $3]++; days[$1] = 1 }
  END {
    for (d in days)
      printf "%s  info %d  warn %d  error %d\n", d, count[d, "INFO"], count[d, "WARN"], count[d, "ERROR"]
  }' "${1:-nas.log}" | sort

echo "The errors:"
awk '$3 == "ERROR" { day = $1; time = $2; $1 = $2 = $3 = ""; sub(/^ +/, ""); print "  " day, time, $0 }' "${1:-nas.log}"
