shell命令统计代码行数

wc -- word, line, character, and byte count
The following options are available:

 -c      The number of bytes in each input file is written to the standard
         output.  This will cancel out any prior usage of the -m option.

 -l      The number of lines in each input file is written to the standard
         output.

 -m      The number of characters in each input file is written to the
         standard output.  If the current locale does not support multi-
         byte characters, this is equivalent to the -c option.  This will
         cancel out any prior usage of the -c option.

 -w      The number of words in each input file is written to the standard
         output.

1、当前文件夹下的js文件数
find . -name ".js"|wc -l
2、当前文件夹下的js文件的代码行数
find . -name "
.js"|xargs cat|wc -l
3、当前文件夹下的js文件去除空行之后的代码行数
grep -v ^$去除空行
find . -name "*.js"|xargs cat|grep -v ^$|wc -l

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容