代码之家  ›  专栏  ›  技术社区  ›  Joe

计算Django项目中的代码行数

  •  11
  • Joe  · 技术社区  · 17 年前

    编辑:shell的东西很酷,但在Windows上呢?

    5 回复  |  直到 9 年前
        1
  •  17
  •   Aiden Bell    17 年前

    是的:

    shell]$ find /my/source -name "*.py" -type f -exec cat {} + | wc -l
    

        2
  •  7
  •   Steve Losh    17 年前

    你可能想看看 CLOC --它不是Django特有的,但它支持Python。它可以显示实际代码、注释、空行等的行数。

        3
  •  4
  •   Xiong Chiamiov    9 年前

    从艾登的回答开始,并提供一些帮助 a question of my own

    # find the combined LOC of files
    # usage: loc Documents/fourU py html
    function loc {
        #find $1 -name $2 -type f -exec cat {} + | wc -l
        namelist=''
        let i=2
        while [ $i -le $# ]; do
            namelist="$namelist -name \"*.$@[$i]\""
            if [ $i != $# ]; then
                namelist="$namelist -or "
            fi
            let i=i+1
        done
        #echo $namelist
        #echo "find $1 $namelist" | sh
        #echo "find $1 $namelist" | sh | xargs cat
        echo "find $1 $namelist" | sh | xargs cat | wc -l
    }
    

    我相信那些比我更有知识的人可以改进这一点,所以我将把它放在社区维基中。

        4
  •  1
  •   Dan Lorenc    17 年前

    查看unix上的wc命令。

        5
  •  0
  •   sharjeel    17 年前

    使用GnuWin32在Windows上获取wc命令( http://gnuwin32.sourceforge.net/packages/coreutils.htm )

    wc*.py