Parse Log File and Count Errors

Easy Shell OS
Solve this problem

Write a shell script that parses a log file and counts the number of lines containing the keyword 'ERROR'. The script should accept a filename as input and print only the total count of error lines.

Constraints

  • Use only standard GNU utilities (grep, awk, sed, wc).
  • Script must accept log filename as command line argument.
  • Output should contain only the integer count, no extra text.
  • Treat case-sensitive matches only (match 'ERROR', not 'error').
  • If the file does not exist, exit with non-zero status.
Starter codeShell
1#!/bin/bash2# TODO: Implement error count