A log can contain three lines mentioning ERROR, four occurrences of the word and two records whose declared severity is ERROR. Each count can be correct. Each answers a different question. This independent Linux writing sample uses a six-record synthetic file to make that distinction inspectable.

The fixture also omits the final newline. That creates a separate boundary: newline characters and displayed records are not necessarily the same count. I checked the file with installed GNU grep 3.11 and GNU coreutils 9.7. No system, customer or application logs are included.

Choose the thing being counted

Our narrow question is how many invented records begin with the severity marker ERROR followed by a space. It is not how many lines contain those letters anywhere. The file includes an informational message, two severity-tagged error records, a warning that quotes ERROR in its message and two other records.

One error record contains the word twice. The warning contains it once despite having a different declared severity. These details let a reader compare the methods without relying on a large or private dataset.

Count matching lines carefully

GNU grep’s count option reports matching lines. With a literal ERROR search, the fixture returns three matching lines: both error records and the warning that mentions the word.

That result is useful for locating text. It does not establish the number of events assigned a particular severity. The distinction comes from the selected pattern and the file’s declared format. A search tool cannot infer which part of a line your application treats as its severity field.

Count occurrences as a different result

Illustrative technical documentation and evidence review workspace
Reused AI-generated editorial concept from BrandItAI’s portfolio. No real customer, product interface, test environment or deployment is depicted.

GNU grep’s only-matching option emits the nonempty matched portions separately. In the fixture, counting those emitted matches gives four occurrences. The record containing the word twice contributes two.

This result measures matched text, not unique events. It also depends on the exact pattern. A more complex regular expression, different casing, an empty match or a different delimiter contract would need additional tests. The sample makes no general claim about arbitrary log formats.

Match the declared severity boundary

The third view uses the beginning-of-record marker required by this invented format. It selects two records. The warning’s quoted word no longer enters the count, while the repeated word inside an error message does not create a second record.

This is the only one of the three displayed metrics that answers the stated severity question. It is still a count of sample records, not a count of incidents. Several records could describe one incident, and some systems spread one event over several lines.

Keep the final newline visible

GNU wc’s line option counts newline characters. Because this fixture ends with a non-newline character, it reports five. A reader can still inspect six logical records in the file. The local check verifies both the missing final newline and the expected outputs.

A data handoff should record that condition instead of silently changing the file to make counts agree. In real work, establish the record delimiter, encoding and handling of multiline messages before turning a command’s output into a report.

Illustrative technical documentation and evidence review workspace
Reused AI-generated editorial concept from BrandItAI’s portfolio. No real customer, product interface, test environment or deployment is depicted.

Show the evidence with the result

The paired desk displays the invented source records, the selected unit and which records contribute. Its local receipt requires the reader to choose the severity-record question and review the count. It executes no shell command and does not read another file.

The complete proposal would extend this example into an agreed practical article after editorial review. This existing AI-assisted sample is a portfolio demonstration, not an accepted Linux Magazine manuscript. Compensation, scope, rights and any publication-specific tooling requirements would need confirmation before a commission begins.

Inspect the supporting review concept · Discuss a scoped project

Download the six invented log records · Checked GNU-tool outputs