Home > bash, RHEL, Slackware > Linux bash: List all directories in a target directory sorted by the size of each found directory

Linux bash: List all directories in a target directory sorted by the size of each found directory

root@xxxx:[Thu Feb 10 14:57:40]:[/apps]$ find /apps/ -maxdepth  1 -type d ! -type l  ! -path "/apps/"   -printf '"%p"\n'  | xargs  --no-run-if-empty  du -s | sort -nk 1,9 | awk '{crap="";for(i=2; i<=NF; i++) {crap=crap" "$i;};printf ("%06.2fG %s\n",$1/1024/1024,crap)}'
000.00G /apps/backups
000.00G /apps/dump_mysql
000.00G /apps/restore
000.01G /apps/dest
000.09G /apps/jre1.5.0_21
000.15G /apps/apache-tomcat-5.5.28
000.19G /apps/software
000.30G /apps/apache-tomcat-5.5.15
000.95G /apps/ops
001.51G /apps/openssl
016.96G /apps/mysql-5.0.86-linux-i686
Advertisements
Categories: bash, RHEL, Slackware Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: