Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ulysses!dgk From: dgk@ulysses.homer.nj.att.com (David Korn[drew]) Newsgroups: comp.unix.wizards Subject: Re: filename substitution question Summary: expanded pattern capabilities with ksh-88 Message-ID: <11372@ulysses.homer.nj.att.com> Date: 25 Mar 89 00:12:39 GMT References: <1627@ncar.ucar.edu> <9911@smoke.BRL.MIL> Organization: AT&T Bell Laboratories, Murray Hill Lines: 26 In article <9911@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn ) writes: > In article <1627@ncar.ucar.edu> rob@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.