gpt4 book ai didi

linux - 在所有子目录上使用 wc 来计算行数

转载 作者:IT老高 更新时间:2023-10-28 12:37:40 25 4
gpt4 key购买 nike

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

cd mydir
wc -l *
..
11723 total

man wc 建议 wc -l --files0-from=-,但我不知道如何将所有文件的列表生成为 NUL-终止名称

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

没用。

最佳答案

你可能想要这个:

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

如果你只想要总行数,你可以使用

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

关于linux - 在所有子目录上使用 wc 来计算行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13727917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com