|
Home > Archive > Unix questions > November 2004 > find/grep file extensions
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 |
find/grep file extensions
|
|
| Irrational Number 2004-11-29, 8:47 pm |
| I'm trying to set up a command like:
find . -name "*.[fcChb]" -exec grep \!* /dev/null \{\} \;
where it will look for all files with the suffixes
of "fcChb". That works fine. However, I
want to add files like:
file.cc
file.CC
How do I add those to this same command? Doing
different combinations of the following did not work:
find . -name "*.[fcChb][cC]" -exec grep \!* /dev/null \{\} \;
find . -name "*.[fcChb] *.[cC][cC]" -exec grep \!* /dev/null \{\} \;
find . -name "{*.[fcChb]}{[cC]}" -exec grep \!* /dev/null \{\} \;
Any ideas?
Thanks in advance,
Anita
| |
| Bill Marcum 2004-11-29, 8:47 pm |
| On Mon, 29 Nov 2004 14:38:39 -0800, Irrational Number
<nospam@nospam.com> wrote:
> I'm trying to set up a command like:
>
> find . -name "*.[fcChb]" -exec grep \!* /dev/null \{\} \;
>
> where it will look for all files with the suffixes
> of "fcChb". That works fine. However, I
> want to add files like:
>
> file.cc
> file.CC
>
> How do I add those to this same command? Doing
> different combinations of the following did not work:
>
> find . -name "*.[fcChb][cC]" -exec grep \!* /dev/null \{\} \;
This should work, but it would also match names ending with .fc, .hc or
.bc
> find . -name "*.[fcChb] *.[cC][cC]" -exec grep \!* /dev/null \{\} \;
> find . -name "{*.[fcChb]}{[cC]}" -exec grep \!* /dev/null \{\} \;
>
find . -name "*.[fcChb]" -o -name "*.[cC][cC]"
If you have GNU find, -iname is case insensitive.
--
"At a scheduled time, the robot would pull the flush lever and scream as
it got sucked down the drain." --Kibo
| |
| Stephane CHAZELAS 2004-11-30, 2:47 am |
| 2004-11-29, 18:53(-05), Bill Marcum:
[...]
> find . -name "*.[fcChb]" -o -name "*.[cC][cC]"
>
> If you have GNU find, -iname is case insensitive.
[...]
You need parenthesis as -a (implied when missing) has higher
precedence than -o
find . -name ... -o -name ... -exec ...
is
find . \( -name ... \) -o \( -name ... -exec ... \)
You need
find . \( -name ... -o -name ... \) -exec ...
--
Stephane
| |
| rakesh sharma 2004-11-30, 7:47 am |
| Irrational Number <nospam@nospam.com> wrote in message news:
>
> I'm trying to set up a command like:
>
> find . -name "*.[fcChb]" -exec grep \!* /dev/null \{\} \;
>
> where it will look for all files with the suffixes
> of "fcChb". That works fine. However, I
> want to add files like:
>
> file.cc
> file.CC
>
find . \( -name "*.[fcChb]" -o -name "*.cc" -o -name "*.CC" \) -exec ...
depending on your version of 'find' it may not be able to detect hidden
files ending with the mentioned extensions.
BTW, are you trying to write up an alias ?
| |
| Irrational Number 2004-11-30, 7:43 pm |
| Stephane CHAZELAS wrote:
> 2004-11-29, 18:53(-05), Bill Marcum:
> [...]
> [...]
>
> You need parenthesis as -a (implied when missing) has higher
> precedence than -o
>
> find . -name ... -o -name ... -exec ...
>
> is
>
> find . \( -name ... \) -o \( -name ... -exec ... \)
>
> You need
>
> find . \( -name ... -o -name ... \) -exec ...
Thanks for your help!
-- Anita --
| |
| Irrational Number 2004-11-30, 7:43 pm |
| Bill Marcum wrote:
> On Mon, 29 Nov 2004 14:38:39 -0800, Irrational Number
> <nospam@nospam.com> wrote:
> This should work, but it would also match names ending with .fc, .hc or
> .bc
I don't mind it finding names ending with .fc, .hc, etc.,
but the above format does NOT find files ending in
..f, .h, etc. I need both the single letter and two-letter
filename suffixes.
>
>
> find . -name "*.[fcChb]" -o -name "*.[cC][cC]"
>
> If you have GNU find, -iname is case insensitive.
Thanks!
-- Anita --
| |
| Irrational Number 2004-11-30, 7:43 pm |
| rakesh sharma wrote:
> Irrational Number <nospam@nospam.com> wrote in message news:
>
> find . \( -name "*.[fcChb]" -o -name "*.cc" -o -name "*.CC" \) -exec ...
>
> depending on your version of 'find' it may not be able to detect hidden
> files ending with the mentioned extensions.
>
> BTW, are you trying to write up an alias ?
THANK YOU, everybody!! I knew the group would
come through.
Yes, I am indeed creating an alias.
-- Anita --
|
|
|
|
|