Difficulty: Easy
Correct Answer: wc
Explanation:
Introduction / Context:
When auditing logs, measuring dataset sizes, or validating script output, a compact summary of lines, words, and bytes is helpful. Unix/Linux provides a standard utility that computes these metrics efficiently for one or many files and can be combined with pipelines for flexible analysis.
Given Data / Assumptions:
Concept / Approach:
The 'wc' command (word count) reports three values by default: line count, word count, and byte count (often interpreted as characters for single-byte encodings). Options '-l', '-w', and '-c' restrict output to a specific metric. With multiple files, 'wc' prints per-file statistics and an aggregate total line at the end.
Step-by-Step Solution:
Verification / Alternative check:
Cross-verify bytes with 'stat -c %s filename' (GNU) and lines with 'nl' or 'awk 'END{print NR}' filename'. The results should match for regular files.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing bytes with characters in multibyte encodings, and forgetting that 'wc' on stdin (for example, 'wc < file') omits the filename in the output format.
Final Answer:
wc
Discussion & Comments