du -x still examines mounted filesystems when using wildcards
You can still filter that using mountpoint
(if available on your system):
for a in /*; do mountpoint -q -- "$a" || du -s -h -x "$a"; done
If mountpoint
is not available but stat
is (while stat
is still not POSIX, it may be more common), you will have to compare the stat
output manually:
rootdevice="$(stat -c %D /)"
for a in /*; do [ "$rootdevice" = "$(stat -c %D -- "$a")" ] && du -s -h -x "$a"; done
I guess you're right. You are actually saying du /dev
, du /sys
, du /usr
, du /home
so the "-x" option is meaningless.
Why don't you loop over it? E.g. find / -maxdepth 1 | egrep -v home|media
will list all dirs except home and media. Then you can pipe the output to a while
loop to du
it.
find / -maxdepth 1 | egrep -v home|media | while read f; do
du -s -h -x "$f";
done