在Linux中,如何找到包含最多子目录或文件的find目录? [英] In Linux, how do I find find directory with the most subdirectories or files?
问题描述
如何在系统上找到文件/子目录数量最多的目录?显然,聪明的答案是/
,但这不是我想要的.
How can I find the directory with the largest number of files/subdirectories in it on the system? Obviously the clever answer is /
, but that's not what I'm looking for.
有人告诉我文件系统不在节点上,所以我怀疑某个地方有很多只是垃圾的文件/目录,我想找到它们.
I’ve been told the filesystem is out of nodes, so I suspect that somewhere there are a lot of files/directories which are just garbage, and I want to find them.
我尝试运行此命令:
$ find /home/user -type d -print | wc -l
查找特定目录.
推荐答案
从当前目录开始,您可以尝试
starting from the current directory, you could try
find . -type d | cut -d/ -f 2 | uniq -c
这将列出从当前目录开始的所有目录,每行用字符"/"分隔,选择字段号"2"(每行以"./"开头,因此您的第一个字段为.")然后仅输出唯一行,并计算该唯一行出现的频率(-c参数).
This will list all directories starting from the current one, split each line by the character "/", select field number "2" (each line starts with "./", so your first field would be ".") and then only outputs unique lines, and a count how often this unique line appears (-c parameter).
您还可以在末尾添加"sort -g".
You could also add an "sort -g" at the end.
这篇关于在Linux中,如何找到包含最多子目录或文件的find目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!