using "find" with multiple -name patterns???

using "find" with multiple -name patterns???

Post by Andrew War » Sat, 08 May 2004 04:02:02



I need to use find with multiple make patterns. Is there any way to do
the equivalent of:

find . -name "*.mk" -name "*ake*" -print

How can this be done simply, in 1 command line (so i can -exec something
on these files)

Thanks in advance

-Andrew

 
 
 

using "find" with multiple -name patterns???

Post by Barry Margoli » Sat, 08 May 2004 04:42:00




Quote:> I need to use find with multiple make patterns. Is there any way to do
> the equivalent of:

> find . -name "*.mk" -name "*ake*" -print

> How can this be done simply, in 1 command line (so i can -exec something
> on these files)

> Thanks in advance

> -Andrew

find . \( -name "*.mk" -o -name "*ake*" \) -print

--

Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

 
 
 

using "find" with multiple -name patterns???

Post by Alan Conno » Sat, 08 May 2004 04:49:55



> I need to use find with multiple make patterns. Is there any way to do
> the equivalent of:

> find . -name "*.mk" -name "*ake*" -print

> How can this be done simply, in 1 command line (so i can -exec something
> on these files)

> Thanks in advance

> -Andrew

You should specify the file type too, so that directories aren't returned.

find . -type f \( -name '*.mk' -o -name '*ake*' \) -exec  whatever {} \;

That do it, Andew?

AC

 
 
 

using "find" with multiple -name patterns???

Post by Andrew War » Sat, 08 May 2004 05:25:25





>>I need to use find with multiple make patterns. Is there any way to do
>>the equivalent of:

>>find . -name "*.mk" -name "*ake*" -print

>>How can this be done simply, in 1 command line (so i can -exec something
>>on these files)

>>Thanks in advance

>>-Andrew

> find . \( -name "*.mk" -o -name "*ake*" \) -print

Thanks very much

-A

 
 
 

using "find" with multiple -name patterns???

Post by rakesh shar » Sun, 09 May 2004 11:53:24



> I need to use find with multiple make patterns. Is there any way to do
> the equivalent of:

> find . -name "*.mk" -name "*ake*" -print

> How can this be done simply, in 1 command line (so i can -exec something
> on these files)

By default, find's operators are stringed along as logical AND. So, in your case
all files whose names end in .mk and then contain the string 'ake' somewhere
in the filename are printed out.But what we need is the OR on the filenames.
Note: all dot files are being ignored here.

find . \( -name '*.mk' -o -name '*ake*' -o \
          -name '.*.mk' -o -name '.*ake*' \) \
-exec ... do something with the captured files \;

 
 
 

using "find" with multiple -name patterns???

Post by Geoff Clar » Tue, 11 May 2004 21:47:18



Quote:>> find . -name "*.mk" -name "*ake*" -print

[snip stuff about using -o]

Quote:> Note: all dot files are being ignored here.

Only true for GNU find.  POSIX-conforming versions of find will
match dot files.

--