"nmkdir" in the Bourne shell at a Unix machine near you.
Ephrayim J. Naiman
naiman at pegasus.UUCP
Wed Aug 28 08:19:49 AEST 1985
<munch, munch>
Here's another nmkdir which makes all the directories in a given path.
It doesn't use expr so it's not so slow.
==========================================================
if [ $# = 0 ]
then
echo "$0: arg count"
exit 2
fi
CWD=`pwd`
for i in $*
do
IFS=/
BUILD=.
# If the directory starts with a slash we have to move there.
if [ "`echo "$i" | cut -c1`" = "/" ]
then
cd "/"
fi
for j in $i
do
BUILD=${BUILD}/${j}
if [ ! -d "$BUILD" ]
then
mkdir "$BUILD"
# Remember the exit code because the test operator has its own exit code.
EXIT=$?
if [ $EXIT != 0 ]
then
exit $EXIT
fi
fi
done
# cd back in case there are more arguments on the argument list that do
# not begin with slash.
cd "$CWD"
done
--
==> Ephrayim J. Naiman @ AT&T Information Systems Laboratories (201) 576-6259
Paths: [ihnp4, allegra, mtuxo, maxvax, cbosgd, lzmi, ...]!pegasus!naiman
More information about the Comp.sources.unix
mailing list