2

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!

sandy
  • 183
  • 1
  • 9

1 Answers1

5

Try:

$ du -h --max-depth=1 2>/dev/null

This redirects stderr (file handle 2) to /dev/null, ignoring any error messages.

e0k
  • 6,961
  • 2
  • 23
  • 30