question is in the title.
I'm trying to perform "du -sh * | grep '^[0-9]'" on my root dir to filter out any ... cannot access ..., but my console will just color matches and print out everything.
Thanks for any help
When you run a command, it will always open 3 files: stdin
(keyboard input), stdout
(command output) and stderr
(command output for error messages), these are numbered from 0 to 2.
Those error messages from du
are written to stderr
, while the normal output is written to stdout
. This allows you to redirect the error messages to /dev/null. This makes the error messages disappear, you don't need grep for that.
du -sh * 2>/dev/null