Showing posts with label du find size filesystem space. Show all posts
Showing posts with label du find size filesystem space. Show all posts

Tuesday, February 13, 2007

Find File Space Usage

Find space used on filesystem level:
du -ks # shows summary of space used on disk in Kb
du -ms # shows summary of space used on disk in Mb
du -gs # show summary of space used on disk in Gb

Find space used on a file level:
find . -type f -ls | awk '{print $7}' | while read size
do
((TSIZE=TSIZE + $size))
done
echo "$TSIZE"

Shows largest files in a directory:
ls -l | sort -k 5rn,5 -k 9fd,9
-k = search criteria
5 = sort column five
r = apply reverse sort
n = numeric sort

Shows files using the most space on the filesystem:
du -ak | sort -k 1rn -k 2fd

Shows users using the most space:
# this space list will not include files or dirs that the current
# user has no read permissions on
ls /home/ | while read a
do
du -sm /home/$a
done 2> /dev/null | sort -k 1n | tail -10



http://www.devdaily.com/unix/edu/examples/sort.shtml
http://www.cs.rit.edu/~vcss231/Labs/Tips/unix-w8.html