Re: egrep oddity
On Sun, 5 Feb 2012 16:03:45 -0500
Neal Murphy <email@example.com> wrote:
> For quite some time now, I've been getting peeved with egrep not
> doing what it should.
> I have Squeese installed and up-to-date. In an xterm running bash or
> on a console running bash or dash, this command:
> ls -C1 | egrep "^[A-Z]"
> returns all lines except those beginning with 'a'. Even the following
> commands exhibit similar behavior:
> alias|sed -e 's/^a/b/'|egrep "^[A-Z]" # passes sed's output
> untouched alias|sed -e 's/^a/A/'|egrep "^[A-Z]" # passes sed's
> output untouched
> These commands behave the same way on another Squeeze installation at
> another location. Also, 'grep -E' behaves the same way.
> The commands behave as expected on a different GNU/Linux system.
> Does anyone else see this behavior? Or do I need to clean my pipe and
> smoke something better?
Fails for me as well. Also, "^[B-Z]" and "^[C-Z]" fail in similar, but
extended, ways. And grep fails in the same way as egrep.
Try grep -P, though. This did what I expected.