World Library  
Flag as Inappropriate
Email this Article

Wc (Unix)

Article Id: WHEBN0000708695
Reproduction Date:

Title: Wc (Unix)  
Author: World Heritage Encyclopedia
Language: English
Subject: Xargs, AWK, WC, Reference desk/Archives/Language/2008 July 11, Literate programming
Collection: Unix Sus2008 Utilities, Unix Text Processing Utilities
Publisher: World Heritage Encyclopedia

Wc (Unix)

wc (short for word count) is a command in Unix-like operating systems.

The program reads either standard input or a list of files and generates one or more of the following statistics: newline count, word count, and byte count. If a list of files is provided, both individual file and total statistics follow.

Sample execution of wc:

$ wc foo bar
     40     149     947 foo
   2294   16638   97724 bar
   2334   16787   98671 total

The first column is the count of newlines, meaning that the text file foo has 40 newlines while bar has 2294 newlines- resulting in a total of 2334 newlines. The second column indicates the number of words in each text file showing that there are 149 words in foo and 16638 words in bar- giving a total of 16787 words. The last column indicates the number of characters in each text file, meaning that the file foo has 947 characters while bar has 97724 characters- 98671 characters all in all.

Newer versions of wc can differentiate between byte and character count. This difference arises with Unicode which includes multi-byte characters. The desired behaviour is selected with the -c or -m switch.

GNU wc used to be part of the GNU textutils package; it is now part of GNU coreutils.


  • wc -l prints the line count (note that if the last line does not have \n, it will not be counted)
  • wc -c prints the byte count
  • wc -m prints the character count
  • wc -L prints the length of longest line
  • wc -w prints the word count

See also

External links

  • wc(1) - Original Unix First Edition manual page for wc.
  • CommandwcThe by The Linux Information Project (LINFO)

This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.