feed-image  Delivered by FeedBurner  ISSN 1836-5930





Poll

Which of following tutorials would you like to see on the Linuxconfig.org?
 
Partner Linux Sites
TuxMachines
DebianAdmin
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
FreeSoftwareLinux
Jam's Ubuntu Blog
All For Linux

wc
Article Index
1. Name
2. Synopsis
3. Frequently used options
4. Examples

1. Name

wc [man page] - print newline, word, and byte counts for each file

2. Synopsis

wc [OPTION]... [FILE]...
wc [OPTION]... --files0-from=F

3. Frequently used options

-c, --bytes      print the byte counts
-m, --chars print the character counts
-l, --lines print the newline counts
-w, --words print the word counts

4. Examples

By default if you pass file as a argument to wc command it prints number of lines, words and characters:
wc /etc/passwd 
wc default output
To instruct wc command to print only number of words contained within file we can use -w option:
wc -w /etc/passwd 
wc words output
Similarly if we need only number of lines we would use -l option:
wc -l /etc/passwd 
wc lines output
For number of characters we need to use -c option:
wc -m /etc/passwd 
wc characters output
wc can also print out a number of bytes within file:
wc -c /etc/passwd 
wc bytes output