On 4/30/21 2:58 AM, Inian Vasanth wrote:

Bash Version: 5.1
Patch Level: 4
Release Status: release

Description:

A wildcard expression after a negate extglob construct is not returning
right results.

Steps

Consider the following files and assume, that I want to exclude files
ending with 8

shopt -s extglob
touch atop_20210330 atop_20210427 atop_20210428
ls -1 atop_20210@(3|4)+([0-4])!(8)
atop_20210330
atop_20210427

But when I add an extra * at the end of the expression like

ls -1 atop_20210@(3|4)+([0-4])!(8)*
atop_20210330
atop_20210427
atop_20210428

Why is it the case? Shouldn't the glob expression just serve the !(8)
pattern to exclude and simply do a no-op for the extra * character?

Don't assume the !(8) has to match one character; it can match zero.
If you want to make sure to match filenames ending in something other
than 8, use an operator like [!8] that will match one character.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to