首页 > 其他 > 详细

使用wc统计代码行数

时间:2018-01-24 10:31:06      阅读:231      评论:0      收藏:0      [点我收藏+]

最近写了一些代码,想统计一下代码的行数,在eclipse中好像没这功能,网上搜了一下才发现原来Linux有一个统计文件行数的命令wc。使用wc可以打印出每个文件和总文件的行数、字数和字节数,如果没有指定文件,则会读取标准输入(一般是终端)做统计。格式如下:

  1. Usage: wc [OPTION]... [FILE]...
  2. -c, --bytes, --chars print the byte counts
  3. -l, --lines print the newline counts
  4. -L, --max-line-length print the length of the longest line
  5. -w, --words print the word counts
  6. --help display this help and exit
  7. --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 -v ^$|wc -l

使用wc统计代码行数

原文:https://www.cnblogs.com/xiaoleiel/p/8340089.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!