list files not matching wild card

Hi
I need a unix command which generates the list of files that dont match the wild card pattern in the current directory

say for example
I have files like
x.addfd.txt.H2012.txt
x.addfd.txt.H2012.txt
x.asegfd.txt.H2012.txt
adfd.bagddf

I need the list of files which dont match x.*.txt.H*.txt
i.e
adfd.bagddf

Thanks in advance.
Your help is appreciated

In Linux you can try with:

find . -maxdepth 1 -type f \! -regex '\./x\..*\.txt\.H.*\.txt$'

--
Bye

with bash, you can enable extglob. ksh probably has similar, but i don't know the option.

$ shopt -s extglob
$ ls !(x.*.txt.H*.txt)
adfd.bagddf
$ ls *
adfd.bagddf  x.asegfd.txt.H2012.txt  x.bar.txt.H2012.txt  x.foo.txt.H2012.txt

put this shopt -s extglob into your ~/.bashrc to make it always available

1 Like

It's the same in Kshell, but there is no shopt that needs to be set. Kshell also allows multiple patterns (e.g. !(*.jpg|*.png) )

If extended globbing is not available in your shell, you could try:

ls | grep -v '^x\..*\.txt.H.*\.txt$'