Afficher un message
Vieux 19/03/2008, 17h47   #2
pk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find & exec for several regexp patterns together

wong_powah@yahoo.ca wrote:

> How to find & exec for several regexp patterns together?
> e.g. How to combine the following commands into one command:
> find . -name "*.aix" -exec rm {} \;
> find . -name "*.sun*" -exec rm {} \;
> find . -name "*.solaris*" -exec rm {} \;
>
> I tried the following commands, but none of them work:
> find . -name "(*.aix|*.sun*|*.solaris*)" -exec rm {} \;
> find . -name "(*.aix\|*.sun*\|*.solaris*)" -exec rm {} \;
> find . -name "\(*.aix|*.sun*|*.solaris*\)" -exec rm {} \;
> find . -name "\(*.aix\|*.sun*\|*.solaris*\)" -exec rm {} \;


See man find, operator "-o".

find \( -name "*.aix" -o -name "*.sun*" -o "*.solaris*" \) -exec rm {} \;

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.
  Réponse avec citation
 
Page generated in 0,05628 seconds with 9 queries