4 # make sure they gave us some arguments.
6 #hmmm: could use the count notation instead of sloppy empty check.
7 # reset first arg to be '*' to do any directories here.
8 #echo changing args to use all subdirs in current dir.
9 set -- $(find . -maxdepth 1 -mindepth 1 -type d) "${@:2}"
10 #echo "arg 1 is now '$1'"
13 # run through all the parameters provided and find any
14 # directories under them (or probably barf if they're not
17 # print the count of files followed by directory name,
18 # with leading zeros to allow sorting, which get
19 # redigested as spaces before showing the list.
20 printf "%06d -- %s\n" $(find "$i" -type f | wc -l) "$i"
22 # provide sorted output based on how many files exist
25 # eat the zeroes but keep the tabular look (i.e. replace each leading zero
26 # with a space). had to do it as cases, since this seems like context-
27 # sensitive matching, which sed will not do, i think).
28 sed -e 's/^000000/ 0/' -e 's/^00000/ /' -e 's/^0000/ /' \
29 -e 's/^000/ /' -e 's/^00/ /' -e 's/^0/ /'