Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* OSF1 grep doesn't do REs?
@ 1998-02-18  5:00 John Chambers (from root account)
  1998-02-18  5:00 ` Charles M Richmond
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: John Chambers (from root account) @ 1998-02-18  5:00 UTC (permalink / raw)



On this Digital UNIX V4.0B (Rev. 564) system, grep and egrep both
seem to absolutely refuse to do regular expressions, and I was sorta
wondering if anyone knew some trick to make them behave normally.

In checking with "man grep", I find that the RE stuff seems to have
been radically expanded, with things called BREs and EREs, and no
apparent clues as to how to tell the little beasties to enable one
or the other.  Is there some magical incantation that's needed to
make it work?

Here's proof of the problem, in a directory with lots of *.c files.
As you can see, there are several examples of 'fork' and 'Fork' in
the files, but '[Ff]ork' doesn't match anything. Using egrep gives
exactly the same output.

===> which grep
/sbin/grep
===> grep fork *.c
conn.c:* Connect two ports together.  This program forks, and each
process then
ping.c:                 perror("ping: fork");
tcpserver.c:* Wait for a connection.  When we get one, we fork off a
child to
root@ral1::jc/src/misc: grep Fork *.c
conn.c: D5("Fork ...");
conn.c: if ((pid1 = Fork()) <= 0) {
conn.c: if ((pid2 = Fork()) <= 0) {
ping.c:         if ((pid = Fork()) < 0) {
proxy.c:                if (Fork()) {
tcpserver.c:    if (child = Fork()) {
===> grep '[Ff]ork' *.c
===>

Tests with any REs other than literal strings always fail.  Patterns
like 'f.*k' and 'f*ork' also fail, though both should match the 'fork'
strings as shown above.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: OSF1 grep doesn't do REs?
  1998-02-18  5:00 OSF1 grep doesn't do REs? John Chambers (from root account)
@ 1998-02-18  5:00 ` Charles M Richmond
  1998-02-20  5:00   ` Mark Taylor
  1998-02-19  5:00 ` Simon Taylor
  1998-02-22  5:00 ` Bob Harris
  2 siblings, 1 reply; 5+ messages in thread
From: Charles M Richmond @ 1998-02-18  5:00 UTC (permalink / raw)
  To: jc


John Chambers (from root account) wrote:
> 
> On this Digital UNIX V4.0B (Rev. 564) system, grep and egrep both
> seem to absolutely refuse to do regular expressions, and I was sorta
> wondering if anyone knew some trick to make them behave normally.
> 
> In checking with "man grep", I find that the RE stuff seems to have
> been radically expanded, with things called BREs and EREs, and no
> apparent clues as to how to tell the little beasties to enable one
> or the other.  Is there some magical incantation that's needed to
> make it work?
> 
> Here's proof of the problem, in a directory with lots of *.c files.
> As you can see, there are several examples of 'fork' and 'Fork' in
> the files, but '[Ff]ork' doesn't match anything. Using egrep gives
> exactly the same output.
> 
> ===> which grep
> /sbin/grep

grep \[Ff\]ork *.c


And by the way...  Do you really want /sbin to be in your PATH before
/usr/bin?

-- 
***********************************************************************
*  Charles Richmond    Integrated International Systems Corporation   *
*  cmr@iisc.com        cmr@koibito.iisc.com  cmr@shore.net            *
*  UNIX Internals, I18N, L10N, X, Realtime Imaging, and  Custom S/W   *
*  One Longfellow Place Suite 3309 , Boston , Ma. USA 02114-2431      *
*  (617) 723 7695    (617) 367 3151        FAX (617) 723 6861         *
***********************************************************************



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: OSF1 grep doesn't do REs?
  1998-02-18  5:00 OSF1 grep doesn't do REs? John Chambers (from root account)
  1998-02-18  5:00 ` Charles M Richmond
@ 1998-02-19  5:00 ` Simon Taylor
  1998-02-22  5:00 ` Bob Harris
  2 siblings, 0 replies; 5+ messages in thread
From: Simon Taylor @ 1998-02-19  5:00 UTC (permalink / raw)



John Chambers (from root account) <jc@eddie.mit.edu> wrote in article
<34EAFC6A.794B@eddie.mit.edu>...
> On this Digital UNIX V4.0B (Rev. 564) system, grep and egrep both
> seem to absolutely refuse to do regular expressions, and I was sorta
> wondering if anyone knew some trick to make them behave normally.
[snip] 
> Here's proof of the problem, in a directory with lots of *.c files.
> As you can see, there are several examples of 'fork' and 'Fork' in
> the files, but '[Ff]ork' doesn't match anything. Using egrep gives
> exactly the same output.
[snip]

You don't need no feelthy single quotes, try:

    grep "[Ff]ork" *.c

(Tested on the same revision of DEC Unix that you have).

Regards,

Simon Taylor



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: OSF1 grep doesn't do REs?
  1998-02-18  5:00 ` Charles M Richmond
@ 1998-02-20  5:00   ` Mark Taylor
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Taylor @ 1998-02-20  5:00 UTC (permalink / raw)



John Chambers (from root account) wrote:
> 
> On this Digital UNIX V4.0B (Rev. 564) system, grep and egrep both
> seem to absolutely refuse to do regular expressions, and I was sorta
> wondering if anyone knew some trick to make them behave normally.
> 
> In checking with "man grep", I find that the RE stuff seems to have
> been radically expanded, with things called BREs and EREs, and no
> apparent clues as to how to tell the little beasties to enable one
> or the other.  Is there some magical incantation that's needed to
> make it work?
> 
> Here's proof of the problem, in a directory with lots of *.c files.
> As you can see, there are several examples of 'fork' and 'Fork' in
> the files, but '[Ff]ork' doesn't match anything. Using egrep gives
> exactly the same output.
> 
> ===> which grep
> /sbin/grep

I don't know if this is your problem but I thought I had very weird
grep problems which I eventually identified (with absolutely no help
from Digital) to be a pattern matching (globbing I guess)
bug in the DU 4.0 /bin/csh.  If you're using the C shell I suggest you 
give the same thing a go in, say ksh and see if that's what the
problem is.

I fixed our problem by copying a /bin/csh from DU 3.2, which isn't
buggy (well, not in that respect).

-----------------------------------------------------------------------
| Mark Beauchamp Taylor  -  physicist trapped in a chemist's body.    | 
| mark.taylor@bris.ac.uk    http://zeus.bris.ac.uk/~chmbt/index.html  |
| Department of Chemistry, University of Bristol, UK                  -------
-----------------------------------------------------| ... It's the future! |
                                                     ------------------------



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: OSF1 grep doesn't do REs?
  1998-02-18  5:00 OSF1 grep doesn't do REs? John Chambers (from root account)
  1998-02-18  5:00 ` Charles M Richmond
  1998-02-19  5:00 ` Simon Taylor
@ 1998-02-22  5:00 ` Bob Harris
  2 siblings, 0 replies; 5+ messages in thread
From: Bob Harris @ 1998-02-22  5:00 UTC (permalink / raw)



In article <34EAFC6A.794B@eddie.mit.edu>, "John Chambers (from root
account)" <jc@eddie.mit.edu> wrote:

> On this Digital UNIX V4.0B (Rev. 564) system, grep and egrep both
> seem to absolutely refuse to do regular expressions, and I was sorta
> wondering if anyone knew some trick to make them behave normally.

> ===> grep '[Ff]ork' *.c

I just tried exactly this same command and it worked correctly.  Therefore
I would suspect your shell being guilty of not properly honoring the single
quota marks.

Try the following .c program to see if the arguments are being passed to
grep the way you expect them to

main(int ac, char **av)
{
    printf("%s\n",av[1]);
}

If your shell is not the problem, then you should see

% test_program '[Ff]ork'
[Ff]ork

If you do not see the string within the quote marks printed out as is, then
your shell is messing with the string before it is passed to the program
(in this case the test program, but in your case grep and anyother command
that accepts strings with []'s in them).

-- 
                                      Bob Harris

I don't get to tell me what to do, I only get to tell me how to do it.
The opinions expressed are my own and do not represent Digital Equipment
Corporation



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1998-02-22  5:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-02-18  5:00 OSF1 grep doesn't do REs? John Chambers (from root account)
1998-02-18  5:00 ` Charles M Richmond
1998-02-20  5:00   ` Mark Taylor
1998-02-19  5:00 ` Simon Taylor
1998-02-22  5:00 ` Bob Harris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox