今日作ったシェルスクリプト

特定ディレクトリ毎のディスク使用量を把握したかった。

#!/bin/sh
#特定ディレクトリ階層でのディスク使用量を表示

for DIR in `ls -1 $1`
do
     du -hs $1/$DIR;
done
$ sh ./checkDiskSpace.sh /home

  20K    /home/a
 346M    /home/ab
  47M    /home/abc
 138M    /home/abcd
  35M    /home/abcde
  11G    /home/abcdefg
  68M    /home/abcdefgh
 1.9M    /home/abcdefghi
 4.8G    /home/abcdefghij
  70M    /home/abcdefghijk
 501M    /home/abcdefghijkl
 256M    /home/abcdefghijklm
 183M    /home/abcdefghijklmn
  56M    /home/abcdefghijklmno
 104M    /home/abcdefghijklmnop
  92M    /home/abcdefghijklmnopq
 1.3G    /home/abcdefghijklmnopqr
  12K    /home/abcdefghijklmnopqrs
  17M    /home/abcdefghijklmnopqrst
 595M    /home/abcdefghijklmnopqrstu