Differences between version 4 and predecessor to the previous major change of CyberLeo/Scraps/duso.
Other diffs: Previous Revision, Previous Author
Newer page: | version 4 | Last edited on Sunday, 6 July 2014 1:43:33 | by CyberLeo | Revert |
Older page: | version 2 | Last edited on Monday, 15 October 2012 8:24:11 | by CyberLeo | Revert |
@@ -1,13 +1,18 @@
Compute a sorted disk usage analysis using du, without including filesystem mountpoints
<code brush="bash">
duso() {
-sudo sh -e
<<"EOF"
-mnt="
$(stat -c %m .)"
-LANG=C ls -1a | grep -Gv '^\.$\|^\.\.$' | while read dent
-do
-
[ "$(stat -c %m
"${dent}")" = "${mnt}" ] && printf "%s\0" "${dent}"
-done | xargs -0 du -sx | sort -bn
+
sudo sh -es
<<"EOF"
+ case
$(uname -s) in
+ Linux) statfs="
stat -c %m" ;;
+ FreeBSD) statfs="stat -f %d" ;;
+ *) echo "Unknown platform $(uname -s)" ;;
+ esac
+ mnt="$(${statfs}
.)"
+
LANG=C ls -1a | grep -Gv '^\.$\|^\.\.$' | while read dent
+
do
+
[ "$(${statfs}
"${dent}")" = "${mnt}" ] && printf "%s\0" "${dent}"
+
done | xargs -0 du -sx | sort -bn
EOF
}
</code>
version 4
Compute a sorted disk usage analysis using du, without including filesystem mountpoints
duso() { sudo sh -es <<"EOF" case $(uname -s) in Linux) statfs="stat -c %m" ;; FreeBSD) statfs="stat -f %d" ;; *) echo "Unknown platform $(uname -s)" ;; esac mnt="$(${statfs} .)" LANG=C ls -1a | grep -Gv '^\.$\|^\.\.$' | while read dent do [ "$(${statfs} "${dent}")" = "${mnt}" ] && printf "%s\0" "${dent}" done | xargs -0 du -sx | sort -bn EOF }