Search a file with specified pattern

May I know how to search for a file whose name is embedded with 3007 but it shouldn't begin or end with 3007. For ex. : 3008ab3007cd1007.

ls ?*3007?*

vgersh99 it w'd select all files having 3007 embedded anywhere.

In recent bash es you can switch on extended pattern matching by $ shopt -s extglob This then would allow you to unselect files starting/ending with 3007, grepping the ones with 3007 in the middle:

ls !(3007*|*3007) | grep ..*3007..*
3008ab3007cd1007
$ ls *3007*
3007ab3007cd1007  3008ab3007cd1007  3008ab3007cd3007

Rudic, my bash isn't supporting this. My Kernel version is 2.6
when I ran shopt it showed that extglob is on.
So, any other go!!
Also is there any means of downloading this feature from net and installing!

I'd be very surprised that your bash should have the extglob option but not the only functions ( extended pattern matching operators) to use it.

Rudic Please find the attachment from which I concluded that those features are not supported.
See if I have missed something to check.

Yes you missed sth: You issued the command with (supposedly) extglob NOT set, and then set extglob to on. Run the cmd again after setting extglob, and report the result!

Rudic, now the extended feature is working. I ran the following.

set extglob
shopt -s extglob

Thanks!

You don't need the first one; it will set positional parameters:

$ set extglob
$ echo $1
extglob

Yes Rudic, the 1st command isn't required.
Referring to my earlier post with screen shot, I might have run "ls !2004*" and forgot the bracket. Hence I wrote that it's not working.
Then with respect to your reply, I thought extglob has to be set in a different way and then 'shopt -s extglob' has to be run.
Then I ran the 2 commands and this time I didn't miss the bracket and hence it worked. So I thought the the 'set extglob' is required. (though I knew that it sets positional parameter).

Thanks a lot!