Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 544
sebastian_t Avatar asked Mar 28 '11 19:03

sebastian_t


1 Answers

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

du -h --exclude "./.*"
like image 130
SiegeX Avatar answered Oct 08 '22 02:10

SiegeX