Excluding hidden files from du command output with --exclude, grep -v or sed

此生再无相见时 提交于 2019-12-04 16:06:49

问题


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 SiegeX for you answer.

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.


回答1:


If running du with no specified path (current dir), use this:

du -h --exclude "./.*"


来源:https://stackoverflow.com/questions/5463884/excluding-hidden-files-from-du-command-output-with-exclude-grep-v-or-sed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!