I want to list the size of all sub-folders in a directory. when I try
du -h --max-depth=1 the output is cluttered with 'Permission denied' statements as such
du: cannot read directory `./folder_name': Permission denied
How can I suppress these warnings?
I tried a workaround by piping the the output to grep as follows
du -h --max-depth=1 | grep -v 'du:'
but that does not seem to be working either!
Try:
$ du -h --max-depth=1 2>/dev/null
This redirects stderr (file handle 2) to /dev/null, ignoring any error messages.