[vox-tech] Shell Scripting Question: Getting a directory name from a 'find' result

Michael Wenk vox-tech@lists.lugod.org
Mon, 23 Jun 2003 10:54:12 -0700


On Monday 23 June 2003 10:54 am, Richard Crawford wrote:
> Suppose I have a short script as such:
>
> find . -name 'wwwboard.html' -print | while read i
> do
>   print $i
> done
>
> how can I pass the name of the directory where $i lurks to another
> variable, such as $dir?


Well, you could do something like:  

MYDIR=$PWD
find . -name 'wwwboard.html' -print | while read i
do
  print $i
done


there's other ways to do it of course, $PWD is the pwd, but if you call cd you 
will change it.  You could also use `pwd`  in a variable to...

Mike

-- 
wenk@praxis.homedns.org
Mike Wenk