• Linux下统计代码行数


    最近写了一些代码,想统计一下代码的行数,在eclipse中好像没这功能,网上搜了一下才发现原来Linux有一个统计文件行数的命令wc。使用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文件数量:
    find . -name "*.py" |wc -l
    
    1. 统计当前目录下,所有py文件行数:
    find . -name "*.py" |xargs cat|wc -l
    
    1. 统计当前目录下,所有py文件行数,并过滤空行:
    find . -name "*.py" |xargs cat|grep -v ^$|wc -l
    
  • 相关阅读:
    运用Python计算Π的多少(大致计算)
    运用python绘制小猪佩奇
    博客园使用指南 wiki
    博客园 — 打赏功能
    新SSM框架整合
    springMVC
    Eclipse转IDEA的配置!!
    Java学习小知识总结
    java-StringBuffer
    博客园自定义主题
  • 原文地址:https://www.cnblogs.com/jiftle/p/15358512.html
Copyright © 2020-2023  润新知