Number of lines of code for all files under the WC Statistics folder under Linux (including subdirectories)

Source: Internet
Author: User

The WC command is used to count the number of rows, words, and letters of the file's contents.

However, if you want to count the number of rows for all the files in a directory, the WC does not provide recursive statistics.

However, you can combine the Find command, for example:

$ Wc-l ' Find-name *.c '

Where the-L parameter is the count of rows, andfind-name *.c is to find all C files under the current directory (including subdirectories)," is the replacement command in the shell."

Of course, there are many ways to achieve this, and I just think it's easier to remember.

The test results are as follows:


Finally, attach a WC to the use of help (man WC)

NAME
Wc-print newline, Word, and byte counts for each file


Synopsis
WC [OPTION] ... [FILE] ...
WC [OPTION] ...--files0-from=f

DESCRIPTION
Print newline, Word, and byte counts for each file, and a all line if more than one file is specified.  With no file, or if file is-, read standard input. A word is a non-zero-length sequence
of characters delimited by white space. The options below is used to select which counts is printed, always in the following order:newline, Word, character, BYTE, maximum line length.

-C,--bytes
Print the byte counts

-M,--chars
Print the character counts

-L,--lines
Print the newline counts

--files0-from=f
Read input from the files specified by nul-terminated names in file F; If F Is-then read names from standard input

-L,--max-line-length
Print the length of the longest line

-W,--words
Print the word counts

--help Display this Help and exit

--version
Output version information and exit

Number of lines of code for all files under the WC Statistics folder under Linux (including subdirectories)

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.