Cory Petkovsek wrote:
> How can I apply a NOT to a regular expression?
Short answer: You can't.
Long answer: It depends.
If you're using grep, use "grep -v" to only print lines that don't
match: egrep -v 'sally|sue' girls
If you're using sh, use "grep -v" instead of shell globbing:
echo `ls -1 | egrep -v 'sally|sue'`
If you're using sed, use the ! operator: sed -n '/sally\|sue/!p' girls
If you're using perl, take a look at the (?!pattern) and (?<!pattern)
constructs, or do this: perl -ne '! /sally|sue/ and print' girls
> Also, programs like grep seem to have much stronger regex support
> than does bash (ie ls)
Yes, that's true. But you can invoke programs like grep from bash.
> What's the deal?
History and gratuitous incompatibility. The Bourne shell's globbing
support was influenced by the wild card support of earlier command
lines like Digital's various OSes and Multics. (The DOS command
line's wildcard abilities are very similar to the Digital shells of
the 1970s.)
Ed and its descendents ({,e,f}grep, sed, ex, vi) were less influenced
by other OSes. And then there's Perl. Perl took regexps much further
than anybody else had considered.
But there has been cross pollination in all directions, so today there
are 100 slightly different variations and it's just about impossible
to keep them all straight.
--
Bob Miller K<bob>
kbobsoft software consulting
http://kbobsoft.com [EMAIL PROTECTED]