|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 {} \; |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
pk wrote:
> find \( -name "*.aix" -o -name "*.sun*" -o "*.solaris*" \) -exec rm {} \; Sorry, should have been find \( -name "*.aix" -o -name "*.sun" -o name "*.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. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
pk wrote:
> pk wrote: > >> find \( -name "*.aix" -o -name "*.sun*" -o "*.solaris*" \) -exec rm {} \; > > Sorry, should have been > > find \( -name "*.aix" -o -name "*.sun" -o name "*.solaris" \) -exec rm {} > \; >8-( find \( -name "*.aix" -o -name "*.sun*" -o name "*.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. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Mar 19, 11:51 am, pk <p...@pk.pk> wrote:
> pk wrote: > > pk wrote: > > >> find \( -name "*.aix" -o -name "*.sun*" -o "*.solaris*" \) -exec rm {} \; > > > Sorry, should have been > > > find \( -name "*.aix" -o -name "*.sun" -o name "*.solaris" \) -exec rm {} > > \; > >8-( > > find \( -name "*.aix" -o -name "*.sun*" -o name "*.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. Thank you very much. A small typo - third regexp should be "-name": find \( -name "*.aix" -o -name "*.sun*" -o -name "*.solaris*" \) -exec rm {} \; |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
wong_powah@yahoo.ca wrote:
> Thank you very much. > A small typo - third regexp should be "-name": > find \( -name "*.aix" -o -name "*.sun*" -o -name "*.solaris*" \) -exec > rm {} \; Yeah, a typo at last, since I hadn't done enough :-) -- 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. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Mar 19, 8:15am, wong_po...@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 {} \; Try this - find . \( -name "*.txt" -o -name "*.pl" -print \) -exec ls -l {} \; |
|
![]() |
| Outils de la discussion | |
|
|