6 WC Command Examples To Count Number of Lines, Words, Characters in Linux
6 WC Command Examples To Count Number of Lines, Words, Characters in Linux
Commands
Linux
A-Z
LINUX COMMANDS 18 I TecMint :
Characters in Linux
Vi/Vim Editor BEGINNER'S GUIDE
by Ravi Saive | Published: February 25, 2013 | Last Updated: January 3, 2015
Learn vi/vim as a Full Text Editor
Download Your Free eBooks NOW - 10 Free Linux eBooks for Administrators | 4 Free Shell Scripting eBooks SHARE
The wc (word count) command in Unix/Linux operating systems is used to nd out number of newline count, +
word count, byte and characters count in a les speci ed by the le arguments. The syntax of wc command as
shown below.
0
# wc [options] filenames
0
The following are the options and usage provided by the command.
Linux Foundation Certi cation
wc -l : Prints the number of lines in a file. 2 Exam Study Guide to LFCS and LFCE
wc -w : prints the number of words in a file.
wc
wc
-c
-m
:
:
Displays the count of bytes in a file.
prints the count of characters from a file.
wc -L : prints only the length of the longest line in a file.
To count number of newlines in a le use the option ‘-l‘, which prints the number of lines from a given le. Say,
the following command will display the count of newlines in a le. In the output the rst led assigned as count
and second eld is the name of le.
When using options ‘-c‘ and ‘-m‘ with ‘wc‘ command will print the total number of bytes and characters
respectively in a le. LINUX EBOOKS