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

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -