[Linux] Linux statistics file line count

Source: Internet
Author: User

Linux provides ready-made commands to count the number of bytes, rows, and other information in a file. The WC command can easily resolve this issue.

The WC command, which can be used to count bytes (byte), Word (word), line (newline), etc. in each file, and if multiple files are given, the total number of rows is also calculated. The word (word) refers to a sequence of characters separated by a space.

How to use:

WC [option] ... [File] ...

The common options [option] are:

-C,--bytes output byte count

-M,--chars output character count

-L,--lines output line number

-w,--words Output Word Count

For example:

WC-LCW Test.txt

Output Result:

577 Test.txt

Among them, 13 is lines,68 for words,577 for bytes.

It is important to note that the order and number of output columns are not affected by the order and number of options, and are always displayed in the order of the number of rows, words, bytes, filenames, and a maximum of one column per item.

Let me give you an example:

WC-LCW a.txt B.txt

The output is:

101 909 4846 A.txt

171 912 B.txt

5758 Total

Where the last line is the sum total of the statistics calculated in the previous file.

In addition, if it is:

WC-LW a.txt B.txt

The output is:

101 909 A.txt

171 B.txt

Total

However, if [option] is the default, it is the same as-LCW

For example: WC a.txt b.txt

The output is:

101 909 4846 A.txt

171 912 B.txt

5758 Total


[Linux] Linux statistics file lines

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.