Unix Shell - Re: How do I find file "findme" in tree "bigtree" searching only

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > August 2007 > Re: How do I find file "findme" in tree "bigtree" searching only





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: How do I find file "findme" in tree "bigtree" searching only
Icarus Sparry

2007-08-22, 1:22 am

On Tue, 21 Aug 2007 23:53:06 +0000, Chris Allen wrote:

> On Aug 21, 3:25 pm, James Michael Fultz <xy...@sent.as.invalid> wrote:
>
> Thanks for that solution. Unfortunately I don't have access to GNU find
> and our security policy prevents me from installing it. I'm working on
> Solaris 8, with the standard built in tools. Is there anyway to do this
> with the regular find command?


It is not clear from your description if you want to find

bigtree/in_here/nothere/findme

or not. If you don't, another way of stating the problem is find the
files named "findme" in directories "in-here". From that it follows that
looking for directories named "in-here" (using find), and then looking in
them directly for "findme" will work.

If you have no reason to suspect weird characters in the filenames (in
particular newline characters) then

find . -type d -name in-here -print | while IFS="" read -r d ; do
if [ -f "$d/findme" ] ; then echo "$d/findme" ; fi
done

If on the otherhand you do want to find "findme" anywhere under "in-
here", then an approach is to list all the findme files, and then use
grep to only select the ones below in-here

find . -type f -name findme -print | grep '/in-here/'

Icarus
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com