Use wc to count lines of code

Usage: wc [OPTION]... [FILE]...
-c, --bytes, --chars print the byte counts
-l, --lines print the newline counts
-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

 

Here are a few examples:

1. Count the number of py files in the current directory:

  1. find . -name "*.py" |wc -l

2. Count the number of lines in all py files in the current directory:

  1. find . -name "*.py" |xargs cat|wc -l

3. Count the number of lines in all py files in the current directory, and filter blank lines:

  1. find . -name "*.py" |xargs cat|grep -^$|wc -l

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324582261&siteId=291194637