Try this "/var/log/{messages,syslog}.?" On Fri, May 16, 2014 at 10:08 AM, Mike Miller <mbmiller+l at gmail.com> wrote: > This is about filename globbing, right? First, for the parentheses to > work, you need to have extended globbing turned on in the bash shell. This > probably means that you have to turn it on in the script, if you are > writing a script. This is the command: > > shopt -s extglob > > More info: > > http://www.linuxjournal.com/content/bash-extended-globbing > > I did this so that I could test some patterns: > > mkdir test > cd test > touch messages syslog anaconda.syslog messages.1 syslog.1 syslog.2.gz > > Using echo or ls does basically the same thing: > > echo !(*.)s*s*g!(*.*) > ls !(*.)s*s*g!(*.*) > > echo !(*.)s*s*g!(*1|*z) > ls !(*.)s*s*g!(*1|*z) > > I see the same thing that you see: > > $ ls !(*.)s*s*g!(*.*) > messages syslog syslog.2.gz > > $ ls !(*.)s*s*g!(*1|*z) > messages syslog > > I don't often use the !() syntax, so it's nice to be reminded of it. > So !(*.)s*s*g!(*.*) matches syslog.2.gz like this: > > !(*.)s * s * g !(*.*) > s y s log.2. g z > > So the g in the pattern is matching with the g in gz, not the g in log. > > It's hard to say what you are shooting for here. That is, what else do > you want to match in addition to the two exact filenames? If I just wanted > the two filenames, I might do this: > > {syslog,messages} > > Mike > > > On Sat, 10 May 2014, gregrwm wrote: > > ok you bashers, check me on this: >> >> matches wanted: messages syslog >> matches not wanted: anaconda.syslog messages.1 syslog.1 syslog.2.gz >> pattern1: !(*.)s*s*g!(*.*) >> pattern1 match results: messages syslog syslog.2.gz syslog.3.gz >> syslog.4.gz >> pattern2: !(*.)s*s*g!(*1|*z) >> pattern2 match results: messages syslog >> >> so pattern2 works. but is that pattern1 result a bug? >> >> _______________________________________________ > TCLUG Mailing List - Minneapolis/St. Paul, Minnesota > tclug-list at mn-linux.org > http://mailman.mn-linux.org/mailman/listinfo/tclug-list > -- Ben Lutgens Linux / Unix System Administrator Three of your friends throw up after eating chicken salad. Do you think: "I should find more robust friends" or "we should check that refrigerator"? -- Donald Becker, on vortex-bug, suspecting a network-wide problem -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20140516/d15456d8/attachment.html>