1#!/bin/bash 2# 3# vtree - make a tree printout of the specified directory, with disk usage 4# in 1k blocks 5# 6# usage: vtree [-a] [dir] 7# 8# Original posted to Usenet sometime in February, 1996 9# I believe that the original author is Brian S. Hiles <bsh29256@atc.fhda.edu> 10# 11usage() 12{ 13 echo "vtree: usage: vtree [-a] [dir]" >&2 14} 15 16while getopts a opt 17do 18 case "$opt" in 19 a) andfiles=-a ;; 20 *) usage ; exit 2 ;; 21 esac 22done 23 24shift $((OPTIND - 1)) 25 26export BLOCKSIZE=1k # 4.4 BSD systems need this 27 28[ $# -eq 0 ] && set . 29 30while [ $# -gt 0 ] 31do 32 cd "$1" || { shift; [ $# -ge 1 ] && echo >&2; continue; } 33 echo -n "$PWD" 34 35 du $andfiles | sort -k 2f | sed \ 36 -e 's/\([^ ]*\) \(.*\)/\2 (\1)/' \ 37 -e "s#^$1##" \ 38 -e 's#[^/]*/\([^/]*\)$#|____\1#' \ 39 -e 's#[^/]*/#| #g' 40 41 [ $# -gt 1 ] && echo 42 shift 43done 44