Linux 查找大小大于 x MB 的目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17599109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:14:21  来源:igfitidea点击:

find directories having size greater than x MB

linuxshellunix

提问by Sandy

Is it possible to find the directories only having size large than x MB. Suppose, I want to find all the directories only whose size is large than 1000MB with only 1 maxdepth under /home, how to find it in ?

是否可以找到大小仅大于 x MB 的目录。假设,我只想在 /home 下找到所有大小大于 1000MB 且只有 1 个 maxdepth 的目录,如何在 .

采纳答案by twalberg

If I'm interpreting your question right, I think this might be what you want:

如果我正确解释您的问题,我认为这可能是您想要的:

cd /home
du -sm * | awk ' > 1000'

This will show all directories in /homethat contain more than 1000MB. If your version of dudoesn't support -m, you can use du -skand adjust the awkbit to look for more than 1,000,000KB instead...

这将显示/home包含超过 1000MB 的所有目录。如果您的版本du不支持-m,您可以使用du -sk并调整awk位来查找超过 1,000,000KB...