Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!ssc-vax!ray3rd From: ray3rd@ssc-vax.UUCP (Ray E. Saddler III) Newsgroups: comp.unix.wizards Subject: Re: Subdirectory listing Summary: Try out this little script... Keywords: directory tree subdirectory Message-ID: <2673@ssc-vax.UUCP> Date: 22 May 89 22:37:00 GMT References: <215@cs.columbia.edu> Distribution: usa Organization: Boeing Aerospace Corp., Seattle WA Lines: 94 In article <215@cs.columbia.edu>, olasov@cs.columbia.edu (Benjamin Olasov) asks: > > I'm interested in finding a unix command usage that will return the complete > path names of all subdirectories below a given directory, so that, given a > directory tree like this: > > ( Example deleted ) > > the command would take the directory of interest as its argument, as in: > > $ mycommand /files/home/users > > and return the subdirectories in the format: > > /files/home/users/user1 > /files/home/users/user2 > /files/home/users/user2/data > /files/home/users/user2/data/bin > /files/home/users/user3 > /files/home/users/user3/docs > /files/home/users/user4 > /files/home/users/user5 > /files/home/users/user6 > /files/home/users/user6/mail > /files/home/users/user6/hacks > > What's the easiest way to do this? > Give this script a spin around the block: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #!/bin/sh # if [ $# = 0 ] then echo "Usage: mycommand " # # You could ask for the directory here, or assume a # default, if you so desired...I opt to exit non-zero # exit 1 else for I in $* do find $I -type d -exec ls -d {} \; done fi exit 0 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Sample usages: $ mycommand Usage: mycommand $ $ mycommand /user4/ray3rd /user4/law /user4/jsk /user4/markb /user4/ray3rd /user4/ray3rd/SYTEK /user4/ray3rd/HUMOR /user4/ray3rd/bin /user4/ray3rd/clock /user4/ray3rd/VTREE /user4/ray3rd/3B1 /user4/ray3rd/block /user4/ray3rd/CADSA /user4/ray3rd/UUMAP /user4/ray3rd/shartest /user4/ray3rd/STANDARDS /user4/law /user4/jsk /user4/markb $ $ mycommand . . ./SYTEK ./HUMOR ./bin ./clock ./VTREE ./3B1 ./block ./CADSA ./UUMAP ./shartest ./STANDARDS $ -- Ray E. Saddler III | __ __ __ __ | UseNet Boeing Aerospace | / / / // //| // | uw-beaver!ssc-vax!ray3rd P.O. Box 3999 m.s. 3R-05 | /-< / //- // |// _ | PhoneNet Seattle, Wa. 98124 USA | /__//_//__ // //__/ | 1+206-657-2824