LINUX--WC command

Source: Internet
Author: User

The function of the WC (Word Count) command in a Linux system is to count the number of bytes, words, and lines in the specified file, and to display the output of the statistic results.

1. Command format:

WC [Options] File ...

2. Command function:

Counts the number of bytes, words, and lines in the specified file, and displays the output of the statistics. This command counts the number of bytes, word count, and number of lines in the specified file. If the file name is not given, it is read from the standard input. The WC also gives the president count of the files specified.

3. Command parameters:

-C Count bytes.

-L counts the number of rows.

-M counts the number of characters. This flag cannot be used with the-C flag.

-W count words. A word is defined as a string separated by a blank, a jump, or a newline character.

-L Prints the length of the longest line.

-HELP Display Help information

--version displaying version information

Common ways:

1. Count the number of files in a directory

Ls-l|wc-l

2. Count the number of rows of a file

Cat Test.txt |wc-l

3. Count the number of words in a file

Cat Test.txt |wc-l

4. Count the number of executable files in a directory

Ls-f | grep *$|wc-l

the executable * number, add a / number to the directory , add an @ to the symbolic link

Example: This directory contains only subdirectories, which are displayed after each directory/

5. Count the number of directories in a directory

Ls-l|grep "^d" |wc-l

LINUX--WC command

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.