Linux Shell WC command

Source: Internet
Author: User

WCCommandTo count the number of bytes, number of words, and number of rows in a specified file, and display the statistical results.

Syntax: WC [Option] file...

Note: This command counts the number of bytes, number of words, and number of lines in a given file. If no file name is provided, it is read from the standard input. WC also provides the President count for all specified files. Is the largest string separated by space characters.

The options of this command are as follows:

-C: counts the number of bytes.

-L number of statistics rows.

-W counts the number of words.

These options can be used in combination.

The order and number of output columns are not affected by the order and number of options. It is always displayed in the following order and each item has at most one column.

Number of lines, number of words, number of bytes, and file name

If there is no file name in the command line, no file name appears in the output.

For example:

$ WC-LCWFile1 file2

4 33 file1

7 52 file2

11 11 85 total

If any option is omitted-LCW, the WC command execution result is the same as the preceding one.

Example:

The WC command is used to calculate the number of lines, words, and characters in a file or multiple specified files. For example:
WC filename
The first column shows the number of rows, the second column shows the number of words, and the third column shows the number of characters.
WC has four optional parameters: l, C, M, W
WC-l filename report row count
WC-C filename report Byte Count
WC-M filename report characters
WC-W filename

 

The command shown today is:Ls-L | WC-L is used to count the number of files in the current directory.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.