Tricks for finding directory space usage.

2016-07-14

Tricks for finding directory space usage.

1
find . -iname "*regex" -printf "%s\n" | awk '{f+=$1}END{print f/(1024 *1024 * 1024),"GB"}'
1
find . -iname "*.regex" -printf "%s\n" | awk '{f+=$1}END{print f}'

another way.

1
find -name \*.regex -print0 | du -ch --files0-from=- |tail -1
1
du -ch -b --max-depth=1 |sort -n|awk '{ print $1/(1024 *1024 * 1024),"gb", $2 }'

Heres almost the same command excluding anything requiring special notation close to zero.

1
du -ch -b --max-depth=1 |sort -n|awk '{ print $1/(1024 *1024 * 1024),"gb", $2 }' |grep -v e-0

another way.

1
du -h | perl -e 'sub h{%h=(K=>10,M=>20,G=>30);($n,$u)=shift=~/([0-9.]+)(\D)/;return $n*2**$h{$u}}print sort{h($b)<=>h($a)}<>;'

another way.

1
du -ch --max-depth=1 --time | perl -e 'sub h{%h=(K=>10,M=>20,G=>30);($n,$u)=shift=~/([0-9.]+)(\D)/;return $n*2**$h{$u}}print sort{h($b)<=>h($a)}<>;'

Comments: