for i in G M K; do du -hsx * | grep "[0-9]$i\b" | sort -nr; done 2>/dev/null
for
loop is to sort results with G or M or K values separately, otherwise sort -n
would just sort everything by the numbers regardless of G M K suffix.grep "[0-9]$i\b"
matches lines containing a digit followed by G or M or K followed by a "word boundary"for i in $(echo -e 'G\nM\nK'); do du -hsx /* 2>/dev/null | grep '[0-9]'$i | sort -rn; done
du -hsx * | sort -rh