wc — Counting
Line/word/byte counting — the measurement tool behind wc -l < file, find | wc -l, and file size checks in safe-delete workflows.
Counting Patterns
Line count
wc -l docs/antora.yml
# Output: 225 docs/antora.yml
# Suppress filename with input redirection
wc -l < docs/antora.yml
# Output: 225
Byte count — used in your safe-delete workflow
wc -c < file.adoc
# Output: 21246
# Used to show file size before confirming delete
Word count
wc -w < docs/antora.yml
# Counts whitespace-delimited tokens
Count multiple files
find docs/modules/ROOT/examples/codex/grep -name '*.adoc' -exec wc -l {} + | sort -rn
# Output:
# 303 total
# 66 .../infrastructure-patterns.adoc
# 55 .../gotchas.adoc
# 39 .../pcre-lookaround.adoc
Count lines matching a pattern (combine with grep -c)
grep -c 'include::' docs/modules/ROOT/pages/codex/grep/index.adoc
# Output: 7 (number of include directives)
# grep -c is often cleaner than grep | wc -l
Count files (combine with find)
find docs/modules/ROOT/pages -name '*.adoc' -type f | wc -l
# Output: 2088
See Also
-
Safe Workflows — uses
wc -cfor file size confirmation -
grep —
grep -ccounts matches (often cleaner thangrep | wc -l)