linux - BASH extglob negate not working as I expect -
suppose have following dir structure
./testdir ./testdir/a.c ./testdir/b.c ./testdir/testdir2/ ./testdir/t.tar
and suppose cwd testdir , want echo directory entries don't have .tar extension.
this works:
echo *.!(tar)
however, expected produce same result not:
echo *!(tar)
only period missing 2nd command. 2nd echo command lists d.tar file. asterisk glob character should match characters , extglob negate should list not end tar.
let's start these files:
$ ls a.b b.c testdir2 t.tar
this matches files have period not have tar
following period:
$ echo *.!(tar) a.b b.c
this matches files not end tar
:
$ echo !(*tar) a.b b.c testdir2
this extglob surprises shouldn't:
$ echo *!(tar) a.b b.c testdir2 t.tar
the *
can match anything, such t.tar
. since not necessary add tar
after t.tar
, match.
Comments
Post a Comment