HxHippy

wc

Print newline, word, and byte counts for each file

Overview

Prints the total number of bytes, words, and lines in each of the given files.

Syntax

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

Common Options

-l, --lines

Print the newline counts.

-w, --words

Print the word counts.

-m, --chars

Print the character counts.

-c, --bytes

Print the byte counts.

-L, --max-line-length

Print the maximum display width.

--files0-from=F

Read input from the files specified by NUL-terminated names in file F; If F is - then read names from standard input.

Examples

$ wc myfile.txt

Displays the newline, word, and byte counts for myfile.txt.

$ wc -l report.doc

Displays only the number of lines in report.doc.

$ wc -w chapter1.txt chapter2.txt

Displays the word counts for chapter1.txt and chapter2.txt, and their total.

$ ls -1 | wc -l

Counts the number of files and directories in the current directory.

$ echo "Hello world" | wc -m

Counts the characters in the string "Hello world" (including the newline from echo).

$ wc -L data.csv

Shows the length of the longest line in data.csv.

word countlinescharactersbytescounttextfilewc