#!/bin/sh #\- filter to indent output from du or find #usage: %[cat filepath or dirpath list] | ind [-t] #-t, put filesize in left hand column, indent file hierarchy as usual #default is to place filesize in parenthesis after filename # #by conor rafferty, stanford #(X-Archive: comp.sources.misc/8709/10) #slightly modified by ja rupley, tucson, arizona FILES="" TFORM=1 while test $# -ge 1; do case $1 in -t) TFORM=0; ;; *) FILES="$FILES $1"; ;; esac shift done #just print the path and its size. In two popular flavors. cat $FILES | awk ' NF == 2 { if('$TFORM') printf "%s(%d)\n", $NF, $1; else printf "%8d\t%s\n", $1, $NF; next } NF == 1 { print next }' | awk ' BEGIN {blank=" " } { for (s=length; s > 0 && substr($0, s, 1) > " " ; s--) ; for (e=length; substr($0, e, 1) != "/" && e > s+1; e--) ; print substr($0, 1, s) substr(blank, 1, e-s-1) substr($0, e); } '