fbpx
Wikipedia

wc (Unix)

wc (short for word count) is a command in Unix, Plan 9, Inferno, and Unix-like operating systems. The program reads either standard input or a list of computer 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.

wc
The wc command
Original author(s)Joe Ossanna
(AT&T Bell Laboratories)
Developer(s)Various open-source and commercial developers
Initial releaseNovember 3, 1971; 52 years ago (1971-11-03)
Written inC
Operating systemUnix, Unix-like, V, Plan 9, Inferno, MSX-DOS, IBM i
PlatformCross-platform
TypeCommand
LicensePlan 9: MIT License

Example edit

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 options.

Through a 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:

$ grep -r "example" |wc  1071 23337 101349 

History edit

wc is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the Single Unix Specification.[1] It appeared in Version 1 Unix.[2]

GNU wc used to be part of the GNU textutils package; it is now part of GNU coreutils. The version of wc bundled in GNU coreutils was written by Paul Rubin and David MacKenzie.[3]

A wc command is also part of ASCII's MSX-DOS2 Tools for MSX-DOS version 2.[4]

The command is available as a separate package for Microsoft Windows as part of the GnuWin32 project[5] and the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities.[6]

The wc command has also been ported to the IBM i operating system.[7]

Usage edit

  • wc -c <filename> prints the byte count
  • wc -l <filename> prints the line count
  • wc -m <filename> prints the character count
  • wc -w <filename> prints the word count
  • wc -L <filename> prints the length of the longest line (GNU extension)

See also edit

References edit

  1. ^ wc – Shell and Utilities Reference, The Single UNIX Specification, Version 4 from The Open Group
  2. ^ wc(1) – FreeBSD General Commands Manual
  3. ^ "wc(1) - Linux man page".
  4. ^ MSX-DOS2 Tools User's Manual by ASCII Corporation
  5. ^ CoreUtils for Windows
  6. ^ Native Win32 ports of some GNU utilities
  7. ^ IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). IBM. Retrieved 2020-09-05.

External links edit

  • wc(1) - Original Unix First Edition manual page for wc.
  • wc(1) – Linux User Commands Manual
  • wc(1) – Plan 9 Programmer's Manual, Volume 1
  • wc(1) – Inferno General commands Manual
  • The wc Command by The Linux Information Project (LINFO)

unix, short, word, count, command, unix, plan, inferno, unix, like, operating, systems, program, reads, either, standard, input, list, computer, files, generates, more, following, statistics, newline, count, word, count, byte, count, list, files, provided, bot. wc short for word count is a command in Unix Plan 9 Inferno and Unix like operating systems The program reads either standard input or a list of computer 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 wcThe wc commandOriginal author s Joe Ossanna AT amp T Bell Laboratories Developer s Various open source and commercial developersInitial releaseNovember 3 1971 52 years ago 1971 11 03 Written inCOperating systemUnix Unix like V Plan 9 Inferno MSX DOS IBM iPlatformCross platformTypeCommandLicensePlan 9 MIT License Contents 1 Example 2 History 3 Usage 4 See also 5 References 6 External linksExample editSample 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 options Through a 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 grep r example wc 1071 23337 101349History editwc is part of the X Open Portability Guide since issue 2 of 1987 It was inherited into the first version of POSIX 1 and the Single Unix Specification 1 It appeared in Version 1 Unix 2 GNU wc used to be part of the GNU textutils package it is now part of GNU coreutils The version of wc bundled in GNU coreutils was written by Paul Rubin and David MacKenzie 3 A wc command is also part of ASCII s MSX DOS2 Tools for MSX DOS version 2 4 The command is available as a separate package for Microsoft Windows as part of the GnuWin32 project 5 and the UnxUtils collection of native Win32 ports of common GNU Unix like utilities 6 The wc command has also been ported to the IBM i operating system 7 Usage editwc c lt filename gt prints the byte count wc l lt filename gt prints the line count wc m lt filename gt prints the character count wc w lt filename gt prints the word count wc L lt filename gt prints the length of the longest line GNU extension See also editList of Unix commandsReferences edit wc Shell and Utilities Reference The Single UNIX Specification Version 4 from The Open Group wc 1 FreeBSD General Commands Manual wc 1 Linux man page MSX DOS2 Tools User s Manual by ASCII Corporation CoreUtils for Windows Native Win32 ports of some GNU utilities IBM IBM System i Version 7 2 Programming Qshell PDF IBM Retrieved 2020 09 05 External links edit nbsp The Wikibook Guide to Unix has a page on the topic of Commands wc 1 Original Unix First Edition manual page for wc wc 1 Linux User Commands Manual wc 1 Plan 9 Programmer s Manual Volume 1 wc 1 Inferno General commands Manual The wc Command by The Linux Information Project LINFO Retrieved from https en wikipedia org w index php title Wc Unix amp oldid 1178083961, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.