grep question

I’m looking for a regular expression that I can use to find occurrences of
‘endl’ in a zillion C++ files but that doesn’t match ‘qendl’.

Can this be done? If so, how?

(It seams like a simple request!)

“Bill Caroselli (Q-TPS)” <QTPS@earthlink.net> wrote:
: I’m looking for a regular expression that I can use to find occurrences of
: ‘endl’ in a zillion C++ files but that doesn’t match ‘qendl’.

: Can this be done? If so, how?

: (It seams like a simple request!)

How about this?

grep -e ‘[^q]endl’ -e ‘^endl’ *.CC


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

OMG!

Thank you, thank you, thank you!

Obviously, regular expressions aren’t my thing.

BUT, why is the second expression ( ‘^endl’ ) necessary at all? It seams to
work without it.


“Steve Reid” <stever@qnx.com> wrote in message
news:ar3gp6$15e$1@nntp.qnx.com

“Bill Caroselli (Q-TPS)” <> QTPS@earthlink.net> > wrote:
: I’m looking for a regular expression that I can use to find occurrences
of
: ‘endl’ in a zillion C++ files but that doesn’t match ‘qendl’.

: Can this be done? If so, how?

: (It seams like a simple request!)

How about this?

grep -e ‘[^q]endl’ -e ‘^endl’ *.CC


Steve Reid > stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

“Bill Caroselli (Q-TPS)” <QTPS@EarthLink.net> wrote in message
news:ar3hdl$8u$1@inn.qnx.com

BUT, why is the second expression ( ‘^endl’ ) necessary at all? It seams
to
work without it.

Never mind. Got it.
It finds occurances at the beginning of the line.
I don’t have any of those.

Bill Caroselli (Q-TPS) <QTPS@EarthLink.net> wrote in message
news:ar3hdl$8u$1@inn.qnx.com

OMG!

Thank you, thank you, thank you!

Obviously, regular expressions aren’t my thing.

Bill, I am not the fan of regular expressions too, so I would do:

grep endl *.CC | grep -v qendl

-xtang

BUT, why is the second expression ( ‘^endl’ ) necessary at all? It seams
to
work without it.


“Steve Reid” <> stever@qnx.com> > wrote in message
news:ar3gp6$15e$> 1@nntp.qnx.com> …
“Bill Caroselli (Q-TPS)” <> QTPS@earthlink.net> > wrote:
: I’m looking for a regular expression that I can use to find
occurrences
of
: ‘endl’ in a zillion C++ files but that doesn’t match ‘qendl’.

: Can this be done? If so, how?

: (It seams like a simple request!)

How about this?

grep -e ‘[^q]endl’ -e ‘^endl’ *.CC


Steve Reid > stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

Previously, Xiaodan Tang wrote in qdn.public.qnx4.devtools:

Bill Caroselli (Q-TPS) <> QTPS@EarthLink.net> > wrote in message
news:ar3hdl$8u$> 1@inn.qnx.com> …
OMG!

Thank you, thank you, thank you!

Obviously, regular expressions aren’t my thing.

Bill, I am not the fan of regular expressions too, so I would do:

grep endl *.CC | grep -v qendl

This is dangerous. If qendl is a variable in the program, it’s
possible to have a line of code like this:

cout << qendl << endl;

Your grep expression would discard this case.

  • Pete