[comp.unix.xenix] Getting DOS directories under Xenix

davidsen@steinmetz.steinmetz.UUCP (William E. Davidsen Jr) (02/19/88)

Here's a little shell script which produces a complete directory of a
DOS disk, including all of the subdirectories of the starting directory.
It runs quite slowly, but is much better than doing it by hand.

:
#!/bin/sh
# shar+ created from directory /usr2/davidsen/bin
# 17:25 on Thu Feb 18, 1988 by davidsen
echo 'x - rdosdir (text)'
sed << 'E!O!F' 's/^X//' > rdosdir
X:
X#!/bin/sh
X#
X# rdosdir - recursive DOS directory for XENIX
X#
X# Author: Bill Davidsen, 12-11-86
X#
X# Arguments:
X#  1 - disk and directory
X#  2 - columns of output (opt)
X#  3 - print colums (opt)
X
X# see if user needs help
Xif [ $# -eq 0 -o "$1" = "-h" ]
Xthen # output help and quit
X echo "\n\n$0: command format, options in [brackets]"
X echo "  $0 StartDir [print cols] [print width]"
X echo "\nExample:"
X echo "  $0 a: 2 90"
X echo "print all directories on disk A:, double column"
X echo "page width of 90 columns"
X exit 0
Xfi
X
X# see if print coulmns specified
Xif [ -n "$3" ]
Xthen
X width=w$3
Xfi
X
X# process the current directory
Xtemp=/tmp/dd.$$			# temp file name
Xdosdir $1 | sort >$temp
Xecho "\n$1\n"
Xpr -${2}${width}t $temp
X
X# build a list of subdirectories
Xsubdir=`awk '
X{ if ($3 == "<DIR>") print $1 "." $2;
X  if ($2 == "<DIR>" && substr($1,1,1) != ".") print $1
X}' $temp`
X
Xfor dirname in $subdir
Xdo
X $0 $1/$dirname $2 $3
Xdone
X
X# clean up
Xrm $temp
E!O!F
newsize=`wc -c < rdosdir`
if [ $newsize -ne 946 ]
then echo "File rdosdir was $newsize bytes, 946 expected"
fi
exit 0

-- 
	bill davidsen		(wedu@ge-crd.arpa)
  {uunet | philabs | seismo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me