|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
Is there an easier way to write this "find" expression to find any files matching either *.bak or *.bck: find . \( -name "*.bck" -o -name "*.bak" \) -print Since all I want is really something like ls *.{bak,bck} but recursively over all subdirectories, I wonder if there's a way to write a similar, shorter expression for the -name argument in find. Thanks! |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Fri, 27 Jul 2007 01:43:48 +0000, wcyee wrote:
> Hi, > > Is there an easier way to write this "find" expression to find any files > matching either *.bak or *.bck: > > find . \( -name "*.bck" -o -name "*.bak" \) -print > > Since all I want is really something like > > ls *.{bak,bck} > > but recursively over all subdirectories, I wonder if there's a way to > write a similar, shorter expression for the -name argument in find. > > Thanks! find . -name '*.b[ac]k' -print |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Jul 26, 9:54 pm, Icarus Sparry <use...@icarus.freeuk.com> wrote:
> find . -name '*.b[ac]k' -print That s - thanks much! What is the best way to find any files matching a list of extensions, e.g.: "*.cpp", "*.c", "*.h", "*.pl" and "*.sh"? |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On 2007-07-27, wcyee <wcyeee@gmail.com> wrote:
> On Jul 26, 9:54 pm, Icarus Sparry <use...@icarus.freeuk.com> wrote: >> find . -name '*.b[ac]k' -print > > That s - thanks much! What is the best way to find any files > matching a list of extensions, e.g.: "*.cpp", "*.c", "*.h", "*.pl" and > "*.sh"? find . -iregex '.*\.\(foo\|bar\|baz\)$' -print |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Jul 27, 1:32 am, Seb <s...@foo.com> wrote:
> On 2007-07-27, wcyee <wcy...@gmail.com> wrote: > > > On Jul 26, 9:54 pm, Icarus Sparry <use...@icarus.freeuk.com> wrote: > >> find . -name '*.b[ac]k' -print > > > That s - thanks much! What is the best way to find any files > > matching a list of extensions, e.g.: "*.cpp", "*.c", "*.h", "*.pl" and > > "*.sh"? > > find . -iregex '.*\.\(foo\|bar\|baz\)$' -print Nice. Thanks! |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
2007-07-27, 05:32(+00), Seb:
> On 2007-07-27, wcyee <wcyeee@gmail.com> wrote: >> On Jul 26, 9:54 pm, Icarus Sparry <use...@icarus.freeuk.com> wrote: >>> find . -name '*.b[ac]k' -print >> >> That s - thanks much! What is the best way to find any files >> matching a list of extensions, e.g.: "*.cpp", "*.c", "*.h", "*.pl" and >> "*.sh"? > > find . -iregex '.*\.\(foo\|bar\|baz\)$' -print [...] That's GNU (and possibly FreeBSD) specific. Even the regexp syntax is not standard. FreeBSD (and possibly other BSDs) also has a -E option for extended regexps. find -E . -iregex '.*\.(foo|bar|baz)$' -print As a zsh user, I just do print -rl -- **/*.(foo|bar|baz) or to include dot files/dirs: print -rl -- **/*.(foo|bar|baz)(D) case insensitively: print -rl -- **/*.(#i)(foo|bar|baz)(D) The good thing is that you can replace print with any other command. -- Stéphane |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
> As a zsh user, I just do
> > print -rl -- **/*.(foo|bar|baz) > > or to include dot files/dirs: > print -rl -- **/*.(foo|bar|baz)(D) > > case insensitively: > print -rl -- **/*.(#i)(foo|bar|baz)(D) > > The good thing is that you can replace print with any other > command. > Thanks. I've been meaning to check out zsh for quite some time. Your examples are really neat. |
|
![]() |
| Outils de la discussion | |
|
|