Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Wc (Unix)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Unix command utility}} {{lowercase}} {{Infobox software | name = wc | logo = | screenshot = Wc-unix.png | screenshot size = | caption = The {{code|wc}} command | author = [[Joe Ossanna]]<br />([[AT&T Bell Laboratories]]) | developer = Various [[open-source software|open-source]] and [[commercial software|commercial]] developers | released = {{Start date and age|1971|11|3}} | latest release version = | latest release date = | programming language = [[C (programming language)|C]] | operating system = [[Unix]], [[Unix-like]], [[V (operating system)|V]], [[Plan 9 from Bell Labs|Plan 9]], [[Inferno (operating system)|Inferno]], [[MSX-DOS]], [[IBM i]] | platform = [[Cross-platform]] | genre = [[Command (computing)|Command]] | license = Plan 9, Inferno: [[MIT License|MIT]]<br />[[coreutils]]: [[GPL-3.0-or-later]] | website = }} '''{{code|wc}}''' (short for '''w'''ord '''c'''ount) is a command in [[Unix]], [[Plan 9 from Bell Labs|Plan 9]], [[Inferno (operating system)|Inferno]], and [[Unix-like]] [[operating system]]s. The program reads either [[standard input]] or a list of [[computer file]]s 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. ==Example== Sample execution of '''wc''': <syntaxhighlight lang="console"> $ wc foo bar 40 149 947 foo 2294 16638 97724 bar 2334 16787 98671 total </syntaxhighlight> The first column is the count of newlines, meaning that the text file <code>foo</code> has 40 newlines while <code>bar</code> 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 <code>foo</code> and 16638 words in <code>bar</code>{{snd}} giving a total of 16787 words. The last column indicates the number of characters in each text file, meaning that the file <code>foo</code> has 947 characters while <code>bar</code> has 97724 characters{{snd}} 98671 characters all in all. Newer versions of <code>wc</code> can differentiate between [[byte]] and [[character (computing)|character]] count. This difference arises with [[Unicode]] which includes multi-byte characters. The desired behaviour is selected with the <code>-c</code> or <code>-m</code> options. Through a [[Pipeline (Unix)|pipeline]], it can also be used to preview the output size of a command with a potentially large output, without it printing the text into the console: <syntaxhighlight lang=console> $ grep -r "example" |wc 1071 23337 101349 </syntaxhighlight> ==History== {{code|wc}} is part of the [[X/Open]] Portability Guide since issue 2 of 1987. It was inherited into the first version of [[POSIX|POSIX.1]] and the [[Single Unix Specification]].<ref>{{man|cu|wc|SUS}}</ref> It appeared in [[Ancient UNIX|Version 1 Unix]].<ref>{{man|1|wc|FreeBSD}}</ref> [[GNU]] <code>wc</code> used to be part of the GNU [[textutils]] package; it is now part of GNU [[coreutils]]. The version of <code>wc</code> bundled in GNU coreutils was written by Paul Rubin and David MacKenzie.<ref>{{cite web |url=https://linux.die.net/man/1/wc |title = wc(1) - Linux man page}}</ref> A <code>wc</code> command is also part of [[ASCII Corporation|ASCII]]'s ''MSX-DOS2 Tools'' for [[MSX-DOS]] version 2.<ref>[https://archive.org/details/MSXDOS2TOOLS MSX-DOS2 Tools User's Manual by ASCII Corporation]</ref> The command is available as a separate package for [[Microsoft Windows]] as part of the [[GnuWin32]] project<ref>[http://gnuwin32.sourceforge.net/packages/coreutils.htm CoreUtils for Windows]</ref> and the [[UnxUtils]] collection of [[Native (computing)|native]] [[Windows API|Win32]] [[porting|ports]] of common GNU Unix-like utilities.<ref>[http://unxutils.sourceforge.net/ Native Win32 ports of some GNU utilities]</ref> The {{Mono|wc}} command has also been ported to the [[IBM i]] operating system.<ref>{{cite web |title=IBM System i Version 7.2 Programming Qshell |language=en |author=IBM |website=[[IBM]] |author-link=IBM |url=https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc |access-date=2020-09-05 }}</ref> ==Usage== *<code>wc -c <filename></code> prints the byte count *<code>wc -l <filename></code> prints the line count *<code>wc -m <filename></code> prints the character count *<code>wc -w <filename></code> prints the word count *<code>wc -L <filename></code> prints the length of the longest line (GNU extension) ==See also== *[[List of Unix commands]] ==References== {{Reflist}} ==External links== {{Wikibooks|Guide to Unix|Commands}} *[http://man.cat-v.org/unix-1st/1/wc wc(1) - Original Unix First Edition manual page for wc]. *{{man|1|wc|die.net}} *{{man|1|wc|Plan 9}} *{{man|1|wc|Inferno}} *[http://www.linfo.org/wc.html The <code>wc</code> Command] by The Linux Information Project (LINFO) {{Unix commands}} {{Plan 9 commands}} {{Core Utilities commands}} [[Category:Unix text processing utilities]] [[Category:Unix SUS2008 utilities]] [[Category:Plan 9 commands]] [[Category:Inferno (operating system) commands]] [[Category:IBM i Qshell commands]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Core Utilities commands
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Lowercase
(
edit
)
Template:Main other
(
edit
)
Template:Man
(
edit
)
Template:Mono
(
edit
)
Template:Plan 9 commands
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Sister project
(
edit
)
Template:Snd
(
edit
)
Template:Template other
(
edit
)
Template:Unix commands
(
edit
)
Template:Wikibooks
(
edit
)