小编Hyp*_*tum的帖子

为什么wc实用程序会生成多行"total"?

我在从Cygwin运行的shell脚本中使用wc实用程序,我注意到输出中有多行"total".

以下函数用于计算源文件中的行数:

count_curdir_src() {
    find . '(' -name '*.vb' -o -name '*.cs' ')' \
        -a '!' -iname '*.Designer.*' -a '!' -iname '.svn' -print0 | \
    xargs -0 wc -l
}
Run Code Online (Sandbox Code Playgroud)

但它对某个目录的输出如下所示:

$ find . '(' -name '*.vb' -o -name '*.cs' ')' -a '!' -iname '*.Designer.*' -a '!' -iname '.svn' -print0 | xargs -0 wc -l
     19 ./dirA/fileABC.cs
    640 ./dirA/subdir1/fileDEF.cs
    507 ./dirA/subdir1/fileGHI.cs
   2596 ./dirA/subdir1/fileJKL.cs
(...many others...)
     58 ./dirB/fileMNO.cs
     36 ./dirB/subdir1/filePQR.cs
 122200 total
  6022 ./dirB/subdir2/subsubdir/fileSTU.cs
    24 ./dirC/fileVWX.cs
(...)
    36 ./dirZ/Properties/AssemblyInfo.cs
    88 ./dirZ/fileYZ.cs …
Run Code Online (Sandbox Code Playgroud)

shell cygwin

6
推荐指数
2
解决办法
980
查看次数

标签 统计

cygwin ×1

shell ×1