9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Ed Wishart ed@cs.unr.edu
Subject: [9fans] Questions
Date: Tue,  2 Sep 1997 10:22:08 -0700	[thread overview]
Message-ID: <19970902172208.Na6KNWbiNZ3CzfLVqumqgLInJAF4D8jfgRhITAdnKjE@z> (raw)

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




             reply	other threads:[~1997-09-02 17:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-02 17:22 Ed [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-10-21  4:32 [9fans] questions Skip Tavakkolian
1997-09-12 19:59 [9fans] Questions Pete
1997-09-11 21:32 Scott
1997-09-11 20:15 David
1997-09-11 11:49 elliott
1997-09-11  9:29 Steve_Kilbane
1997-09-11  9:08 elliott
1997-09-10 18:17 rob
1997-09-10 18:09 Scott
1997-09-10 17:38 rob
1997-09-10 17:35 Scott
1997-09-10 13:46 Markus
1997-09-10 13:06 
1997-09-03  9:42 Steve
1997-09-03  9:37 Steve
1997-09-02 15:27 Nigel
1997-09-02 15:02 elliott
1997-09-02 13:25 
1997-08-15 20:10 [9fans] questions 

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19970902172208.Na6KNWbiNZ3CzfLVqumqgLInJAF4D8jfgRhITAdnKjE@z \
    --to=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).