Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site pegasus.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!pegasus!naiman From: naiman@pegasus.UUCP (Ephrayim J. Naiman) Newsgroups: net.sources Subject: Re: "nmkdir" in the Bourne shell at a Unix machine near you. Message-ID: <2542@pegasus.UUCP> Date: Tue, 27-Aug-85 18:19:49 EDT Article-I.D.: pegasus.2542 Posted: Tue Aug 27 18:19:49 1985 Date-Received: Fri, 30-Aug-85 07:24:57 EDT References: <1052@sdcsvax.UUCP> <309@cxsea.UUCP> Organization: AT&T Information Systems, Lincroft NJ Lines: 44 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