Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

dir_usage_info

By: a guest on Jan 15th, 2013  |  syntax: Bash  |  size: 0.55 KB  |  views: 74  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. if [ $# -ne 0 -a -d "$1" ]
  4. then
  5.     cd "$1"
  6. fi
  7.  
  8. du -akx . 2> /dev/null | while read SIZE FILENAME
  9. do
  10.         STATTYPE=$(stat -c %F "$FILENAME" 2> /dev/null)
  11.         case "$STATTYPE" in
  12.         [Dd]irectory)
  13.                 TYPE=d
  14.                 ;;
  15.         [Rr]egular?[Ff]ile|regular?empty?file)
  16.                 TYPE=f
  17.                 ;;
  18.         [Ss]ymbolic?[Ll]ink)
  19.                 TYPE=l
  20.                 ;;
  21.         Character?Device|character?special?device)
  22.                 TYPE=c
  23.                 ;;
  24.         Block?Device|block?special?file)
  25.                 TYPE=b
  26.                 ;;
  27.         [Ss]ocket)
  28.                 TYPE=s
  29.                 ;;
  30.         Fifo?File|fifo)
  31.                 TYPE=p
  32.                 ;;
  33.         *)
  34.                 TYPE='?'
  35.                 echo "unknown type $STATTYPE"
  36.                 ;;
  37.         esac