On Sep 25, 12:19pm, Mike Starke wrote:
> On Thu, Sep 25, 2003 at 10:02:37AM -0700, David A. Sinck wrote:
> /_
> /_Actually, it's shell wildcarding that you're looking for.
> /_
> /_cp a[2-6].ext destination
> /_
> /_cp a[3-6][0-9][0-9].ext destination
> /_
> /_cp a[1-8]*[0-9].ext destination
> /_
>
> After I fired off the message I realized I had a bad subject line.
> I tried your first example with a "no match' returned.
>
> I'll play a bit longer to see what simple thing I am missing.
I think that David's suggestion is what you're looking for, but
suppose for the moment that you really did want to use a regular
expression instead of the less powerful (though frequently less
verbose) pattern matching mechanisms provided by the shell. You might
do it (for your example) like this:
cp `ls * | egrep 'a[2-6]\.ext'` destination
(Pay close attention to the type of quote character...)
Here's an example which matches a pattern that'd be lengthier to specify
using the shell's globbing syntax:
cp `ls * | egrep 'x[2-6]{10,15}y'` destination
This would copy all files whose names begin with 'x' and end with 'y' where
there are between 10 to 15 (inclusive) occurrences of the digits 2 thru
6 between the 'x' and 'y'.
Kevin