在所有子目录上使用wc来计算行数之和 [英] Use wc on all subdirectories to count the sum of lines

查看:108
本文介绍了在所有子目录上使用wc来计算行数之和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用wc计算所有子目录中所有文件的所有行?

How can I count all lines of all files in all subdirectories with wc?

cd mydir
wc -l *
..
11723 total

man wc建议使用wc -l --files0-from=-,但我不知道如何将所有文件的列表生成为NUL-terminated names

man wc suggests wc -l --files0-from=-, but I do not know how to generate the list of all files as NUL-terminated names

find . -print | wc -l --files0-from=-

没有用.

推荐答案

您可能想要这样:

find . -type f -print0 | wc -l --files0-from=-

如果仅需要总行数,则可以使用

If you only want the total number of lines, you could use

find . -type f -exec cat {} + | wc -l

这篇关于在所有子目录上使用wc来计算行数之和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆