here is a small script to show the size of directories and files under linux . This will do what du command does but displays in a nice format.You can use this like treesize free tool for linux (: .
Save this script with some name like filesz in /usr/bin and make it executable . Type the command filesz from any directory to check the file/directory sizes
# vi filesz
copy the script and !wq to save changes
#cp filesz /usr/bin
#chmod +x /usr/bin/filesz
####script starts##################
#/bin/sh
du -k --max-depth=1 | sort -nr | awk '
BEGIN {
split("KB,MB,GB,TB", Units, ",");
}
{
u = 1;
while ($1 >= 1024) {
$1 = $1 / 1024;
u += 1
}
$1 = sprintf("%.1f %s", $1, Units[u]);
print $0;
}
'
##########script ends################################

0 Comments