filename substitution question

David Korn[drew] dgk at ulysses.homer.nj.att.com
Sat Mar 25 10:12:39 AEST 1989


In article <9911 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn ) writes:
> In article <1627 at ncar.ucar.edu> rob at scdpyr.ucar.edu (Robert Montgomery) writes:
> >Often it would be simpler to specify what I *don't* want in filename
> >substitution than what I do.  For example, I would like to do something
> >similar the following:
> >	ls {NOTfrog}.c
> >and have it produce:
> >	bird.c		fish.c
> 


ksh-88 has expanded the file matching capability to allow such matches.

The pattern !(frog) matches anything except frog, so that
ls !(frog)*.c matches any thing that ends in .c that does not
start with frog.  More commonly,
	ls !(*.o)
matches anything except *.o.  You can use | for alternation.
For example
	ls !(foo|bar)*.c
whill not match anything beginning with foo or bar.  The notation
	?(pattern-list) matches 0 or 1 or any pattern in list.
	+(pattern-list) matches 1 or more
	*(pattern-list) matches 0 or more of any pattern in list.

Of course these pattern can also be used with case statement and substrings.



More information about the Comp.unix.wizards mailing list