Reputation: 4044
Say I have a list of files in dir like so:
blackneasy-sq.png
dima-sq.png
envoy-sq.png
fox-sq.png
freeze-sq.png
ministarstvo kulture-sq.png
naxi-sq.png
pick-sq.png
pink-sq.png
wink-sq.png
brick-sq.png
rider-sq.png
sixt-rent-a-car.png
slavija hotel-sq.png
temet-sq.png
tepe-sq.png
How would I specify exclude pattern to show all files except those that
contain ck
chars glued together anywhere in filename?
So in a resulting list, files:
blackneasy-sq.png
pick-sq.png
brick-sq.png
should not be shown.
I tried this without success.
print -l [[:alpha:]]*^ck*.*
Upvotes: 0
Views: 290
Reputation: 107769
Use the ~
operator: THIS~THAT
matches files that match the pattern THIS
but not THAT
. This requires the extended_glob
option (which is automatically turned on in some contexts such as completion function, but is not the default state).
print -l -- *.png~*ck*
You can abbreviate *~THAT
to ^THAT
(also requiring extended_glob
), so if you don't want to limit to .png
files, you can use
print -l -- ^*ck*
Upvotes: 2