From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 2 Sep 1997 10:22:08 -0700 From: Ed Wishart ed@cs.unr.edu Subject: [9fans] Questions Topicbox-Message-UUID: 615a5320-eac8-11e9-9e20-41e7f4b1d025 Message-ID: <19970902172208.Na6KNWbiNZ3CzfLVqumqgLInJAF4D8jfgRhITAdnKjE@z> Here are a couple of rc scripts that I wrote some years back to look for files in the file system hierarchy . They run slow but do maintain the limited view of the file system one gets ignoring binds. e.g. started in home directory, they will search rc/bin but not get lost in /bin even though rc/bin is bound to /bin. --------------------------------------- #!/bin/rc #recursive decent of file system, with local directory stack and #internal execution of this file. ed wishart, nov '93 if(~ $#* 0 1) { echo 'Usage: find directory file1 file2 ...' exit 1 } dir = $1 shift if(! test -d $dir) { echo 'First argumant must be a directory' exit 1 } cd $dir for(file in `{ls}) { if(~ $file $*) { echo `{pwd}^/^$file } if(test -d $file) { dstack = `{echo `{pwd} $dstack} # echo 'dstack =' $dstack . find $file $* cd $dstack(1) dstack = $dstack(`{seq 2 $#dstack}) } } -------------------------------------------------------- #!/bin/rc #recursive traversal of file tree with environments managed by #rc o its execution stack. ed wishart nov '93 if(~ $#* 0 1) { echo 'Usage: find directory file1 file2 ...' exit 1 } dir = $1 shift if(! test -d $dir) { echo 'First argumant must be a directory' exit 1 } cd $dir for(file in `{ls -p }) { if(~ $file $*) { echo `{pwd}^/^$file } if(test -d $file) { find2 $file $* } } Note, the above assumes file in named find2 ed wishart