HP3000-L Archives

October 2001, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Proudfoot, Bill" <[log in to unmask]>
Reply To:
Proudfoot, Bill
Date:
Thu, 25 Oct 2001 16:08:06 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (117 lines)
Haven't particularly thought it out, but is there any mileage
in

        find . | grep -v {pattern list}   ?

Bill


> *     +44 (0)151-235-3055
Fax: +44 (0)151-235-3151
> *   mailto:[log in to unmask]
>
>


-----Original Message-----
From: john [mailto:[log in to unmask]]
Sent: 24 October 2001 23:01
To: [log in to unmask]
Subject: Re: [HP3000-L] find command: using a varible to exclude files


Mark Bixby <[log in to unmask]> wrote in message
news:<[log in to unmask]>...
> Ooooh, this was a good one!  :-)
>
> john wrote:
> >
> > Hello,
> > I need help with the find command for a korn shell script I am
> > writting for the HP-UX rel 10.20. When I attempt to use a variable in
> > the following statements I get hits for files that I wanted to be
> > excluded. If I replace the contents of the variable directly into the
> > statement, then the output is OK. It appear to me that when a variable
> > is used the single qoute (') around *.fail are being interprited wrong
> > (yes, the  must be there or it will not work if there are more that
> > one file of that type). I realize this seems trivial but this is just
> > an example. The real variable I intend to use has about 35 different
> > file types that I am trying to exclude and is used in multiple places.
> >
> > to try this out, create the following four test files containing any
> > text.
> > find_ok_1.fail
> > find_ok_2.fail
> > find_ok_1.pass
> > find_ok_2.pass
> >
> > execute the following and the output is correct.
> >
> > for i in `find . \( -type f ! -name '*.fail' \)`
> > do
> >    echo $i
> > done
> >
> > now, execute this and it doesn't work (it finds the "fail" files)
> >
> > file_exclude="-type f ! -name '*.fail'"
> > for i in `find . \( $file_exclude \)`
>
> Try this instead:
>
> for i in `eval "find . \( $file_exclude \)"`
>
> > do
> >    echo $i
> > done
>
> What appeared to be happening in the original was that the single quotes
around
> the -name value were being passed to the find command instead of being
stripped
> by the shell.  The call to eval forces the shell to parse everything a
second
> time, removing the quotes.
>
> I have no idea if this behavior is documented somewhere or is a bug.



To everyone who helped me, thank you. I decided to go with the
following (from mark bixby).

for i in `eval "find . \( $file_exclude \)"`
do
echo $I
done


Thanks again.

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *


***********************************************************************
Confidentiality: This e-mail and its attachments are intended for the
above named recipient(s) only and may be confidential and/or
privileged. If they have come to you in error you must take no action
based on them, nor must you copy or disclose them or any part of their
contents to any person or organisation; please reply to this e-mail
and highlight the error immediately and delete this e-mail and its
attachments from your computer system.

Security Warning: Please note that this e-mail has been created in the
knowledge that Internet e-mail is not a 100% secure communications
medium. We advise that you understand and observe this lack of
security  when e-mailing us.

Viruses: Although we have taken steps to ensure that this e-mail and
its attachments are free from any virus, we advise that in keeping
with  good computing practice the recipient should ensure they are
actually  virus free
***********************************************************************

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2