Your task is to compute a per-error-code tally from an archive of log files. The archive is located at /data/logs/archive-2020-02-06.tar.gz. After extracting, scan all contained .log files for lines indicating an error and extract the error code that follows the word ERROR. Build a summary listing each code and its total occurrences, one per line in the format CODE: COUNT, sorted by CODE. Write the results to /app/summary.txt. If no errors are found, create /app/summary.txt containing a single line: NO_ERRORS.
Steps:
Extract the archive to a temporary directory using tar -xzf to /tmp/logs
Parse every line matching the pattern ERROR <CODE> where CODE is alphanumeric
Count occurrences per code and write CODE: COUNT to /app/summary.txt, sorted by CODE
If there are zero matches, write NO_ERRORS to /app/summary.txt
Ensure you do not leave large intermediate files behind (optional clean-up)
Hints:
Use tar -xzf /data/logs/archive-2020-02-06.tar.gz -C /tmp/logs
Use grep -roE to locate error lines and extract codes; then use sort and uniq to count