My directory looks like this:
$ ls
total 0
-rw-r--r-- 1 user user 0 Jun 18 22:44 file0
-rw-r--r-- 1 user user 0 Jun 18 22:44 file1
-rw-r--r-- 1 user user 0 Jun 18 22:44 file2
-rw-r--r-- 1 user user 0 Jun 18 22:44 file3
-rw-r--r-- 1 user user 0 Jun 18 22:44 file4
-rw-r--r-- 1 user user 0 Jun 18 22:44 file5
-rw-r--r-- 1 user user 0 Jun 18 22:44 file6
-rw-r--r-- 1 user user 0 Jun 18 22:44 file7
-rw-r--r-- 1 user user 0 Jun 18 22:44 file8
-rw-r--r-- 1 user user 0 Jun 18 22:44 file9
Using bash globbing, I want to match file2 to file6, excluding file3.
Since I could not find an and operator for matching multiple patterns, I figured I just use DeMorgan's law that a AND b is equivalent to !(!a OR !b) and write
!(!(file[2-6])|file3)
which works as expected:
$ echo !(!(file[2-6])|file3)
file2 file4 file5 file6
Is there an easier, more direct way to achieve this?
pattern1but notpattern2.4fromfile[23456]. You may want to update your question with a further explanation of the general issue so that people here don't think you're interested in the specific example you are showing (which is now the case).