Bash-查找超过3行的文件列表 [英] Bash -- find a list of files with more than 3 lines
本文介绍了Bash-查找超过3行的文件列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文件目录,并且我想查找包含两行以上文件的列表.
I have a directory of files and I want to find a list of files who has more than 2 lines.
我知道我可以使用wc -l测试每个文件,但是如何将其包装在bash中呢?
I know I can use wc -l to test each file, but how do I wrap it up in bash?
很抱歉,刚开始使用bash的新手问题.
Sorry for the newbie question, new to bash.
推荐答案
您可以使用以下 find
命令:
find . -type f -exec bash -c '[[ $(wc -l < "$1") -gt 2 ]] && echo "$1"' _ '{}' \;
这篇关于Bash-查找超过3行的文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文