使用wc统计代码行数

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

 

下面举几个例子:

1.统计当前目录下,py文件数量:

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

2.统计当前目录下,所有py文件行数:

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

3.统计当前目录下,所有py文件行数,并过滤空行:

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

猜你喜欢

转载自www.cnblogs.com/qiminghaonan/p/8888949.html