Post by GrimbleUsing du -d 1 to get some directory sizes, I also get many
du: cannot access.../read... messages
I thought to suppress them by piping them to sed
du -d 1 | sed '/du:/d'
but doesn't work. Am I misunderstanding the sed command?
[***@x3 home]$ pwd
/home
[***@x3 home]$ du -d 1
6.0G ./dave
4.0K ./rpms
du: cannot read directory './garage/.dbus': Permission denied
du: cannot read directory './garage/.ssh': Permission denied
du: cannot read directory './garage/.gnupg': Permission denied
du: cannot read directory './garage/tmp': Permission denied
76K ./garage
du: cannot read directory './tester/.dbus': Permission denied
du: cannot read directory './tester/.local': Permission denied
du: cannot read directory './tester/.cache/chromium': Permission denied
du: cannot read directory './tester/.cache/dconf': Permission denied
du: cannot read directory './tester/.cache/gvfs': Permission denied
du: cannot read directory './tester/.cache/mozilla': Permission denied
du: cannot read directory './tester/.cache/doc': Permission denied
du: cannot read directory './tester/.pki': Permission denied
du: cannot read directory './tester/.gnupg': Permission denied
du: cannot read directory './tester/.config/chromium': Permission denied
du: cannot read directory './tester/.config/ibus': Permission denied
du: cannot read directory './tester/.config/pulse': Permission denied
du: cannot read directory './tester/.config/dconf': Permission denied
du: cannot read directory './tester/tmp': Permission denied
du: cannot read directory './tester/.mozilla/firefox': Permission denied
2.8G ./tester
8.8G .
[***@x3 home]$ du -d 1 2>/dev/null
6.0G ./dave
4.0K ./rpms
76K ./garage
2.8G ./tester
8.8G .
[***@x3 home]$
The error messages from the du command go to STDERR, not STDOUT. The sed command
is only seeing the non-error output.
With "du -d 1 2>/dev/null" the good output still goes to STDOUT, but the error
messages are suppressed by redirecting them to the null output device.
Regards, Dave Hodgins