Text processing

Linux wc command

Count lines, words, and bytes. Use -l for a line count only.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

wc [OPTION]... [FILE]...

Examples

Count lines in a log file.

wc -l access.log

Count words in a text file.

wc -w README.md

Parameters, options and clauses

Option / clauseDescription
-l, --linesPrint newline counts.
-w, --wordsPrint word counts.
-c, --bytesPrint byte counts.
-m, --charsPrint character counts.
-L, --max-line-lengthPrint the maximum line width.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory