name = "log_parser" category = "b" description = """ Read log lines from stdin. Each line has the format: "LEVEL: message" where LEVEL is one of ERROR, WARN, INFO. Count occurrences of each level and print a summary sorted by level name. Format: "LEVEL: count" """ bash_source = """ #!/bin/bash while IFS= read -r line || [[ -n "$line" ]]; do echo "${line%%:*}" done | sort | uniq -c | while read -r count level; do echo "$level: $count" done """ [[test_cases]] stdin = """ERROR: disk full INFO: started WARN: low memory ERROR: timeout INFO: completed""" expected_stdout = """ERROR: 2 INFO: 2 WARN: 1""" [[test_cases]] stdin = """INFO: boot INFO: ready INFO: shutdown""" expected_stdout = "INFO: 3"