bash 使用 --exclude、grep -v 或 sed 从 du 命令输出中排除隐藏文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5463884/
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
Excluding hidden files from du command output with --exclude, grep -v or sed
提问by sebastian_t
I'm trying to check with Disk Usage tool how big are my home directory folders but it also prints out folders and files starting with dot.
我正在尝试使用磁盘使用工具检查我的主目录文件夹有多大,但它也会打印出以点开头的文件夹和文件。
I can't seem to filter them out.
我似乎无法过滤掉它们。
du -h --exclude="?"
du -h | grep -v "?"
du -h | grep -ve "?"
du -h | sed "?"
Thanks in advance.
提前致谢。
edit> Thank you SiegeXfor you answer.
编辑> 谢谢SiegeX的回答。
du -h --max-depth=1 | grep -v "./\."
Since dot matches any character we have to prefix it with double backslash since its also a special character.
由于点匹配任何字符,我们必须在它前面加上双反斜杠,因为它也是一个特殊字符。
回答by SiegeX
If running duwith no specified path (current dir), use this:
如果在du没有指定路径(当前目录)的情况下运行,请使用:
du -h --exclude "./.*"

