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.