Friday, May 24, 2013

one liner for file system size in GB sorted.

This command will generate the output to check the file systems in GB larger on the top.
cd to the directory you want this command to run on.

 du -sh * | egrep '([0-9][G])' | sed 's/[0-9][K,M]//g' | sort -rn

I ran this and found that, this works but with one glitch. It is going to return the file names too with size if the file names have "G" exactly in the name. To overcome this run following for loop in the directory which sub-directories file size you want to count.

for i in `ls -l  | grep "^d" | awk '{print  $9}'`  ; do du -sh $i ; done | egrep '([0-9][G])' | sort -rn

Thanks

No comments: