Saturday, June 11, 2016

Find out Largest directory size in Ubuntu 16.04

This commands will help you to identify which directory has the largest size, the result will be the list of directory and files with its size
...
747 M hue
781 M incubator-zeppelin-0.5.0
798 M zeppelin-0.5.0
...

Put this script on directory that you want to view
du -sh * | 
sed 's/\([[:digit:]]\)\t/\1B\t/' | 
sed 's/\(.\t\)/\t\1/' | 
sed 's/G\t/Z\t/' | 
sort -n -k 2d,2 -k 1n,1 | 
sed 's/Z\t/G\t/'       

the sample result will be as follow
data@data-stg:/opt$ du -sh * | 
sed 's/\([[:digit:]]\)\t/\1B\t/' | 
sed 's/\(.\t\)/\t\1/' | 
sed 's/G\t/Z\t/' | 
sort -n -k 2d,2 -k 1n,1 | 
sed 's/Z\t/G\t/'       
4.0     K       derby.log
4.0     K       jupyterhub_cookie_secret
4.0     K       jupyterhub.sh
4.0     K       n
4.0     K       spark-class-check_example.sh
8.0     K       jupyterhub.sqlite
8.0     K       pio.log
16      K       pio_ori.sh
68      K       lorem-10000.txt
3.8     M       metastore_db
3.9     M       zeppelin-0.5.0-incubating
11      M       spark-dependencies
334     M       spark-kernel
446     M       PIO_SOURCE
747     M       hue
781     M       incubator-zeppelin-0.5.0
798     M       zeppelin-0.5.0
1020    M       PIO
1.1     G       spark-1.4.1-bin-hadoop2.6
7.5     G       hadoop-2.6.0

No comments :

Post a Comment