Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Subject: Re: grep to == vms search/window ??
Date: 1995/08/03	[thread overview]
Message-ID: <3vqe9j$5g7@news.ox.ac.uk> (raw)
In-Reply-To: 3vormk$18g@expert.cc.purdue.edu

In article <3vormk$18g@expert.cc.purdue.edu>,
The Artist <snafu@expert.cc.purdue.edu> wrote:
>i'm running dec osf v3.2a
>
>i'm trying to make the grep command act similary to
>the vms *search foo.bar string/window=(3,3)*. and
>ideas?  it would allow me to search the file foo.bar
>for the string *string*.  then, if it finds it,
>it would display the line containing the string AND
>three lines directly above it, and three lines 
>directly below it.  any help?

Use GNU grep instead: the option -3 displays 3 lines either side of
each match. If you want an asymmetric window then you can use, e.g.,
-A 4 -B 5 to display 4 lines after and 5 lines before each match.

You'll also find that in its "fixed string" incarnation, it doesn't
have the same bugs as the fgrep supplied in OSF/1 3.0. It might be
fixed in 3.2c but I doubt it.
    % echo abacababacababc | fgrep abacababc
    % echo abaabaac | fgrep abaac
    % 
(actually these and similar bugs are present in most BSD and SysV
fgreps but, interestingly, they have different bugs. OSF/1 shows
the same bug as the SysV fgrep whereas Ultrix shows the same bug
as the BSD one.)

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Oxford University Computing Services
"Widget. It's got a widget. A lovely widget. A widget it has got." --Jack Dee



  parent reply	other threads:[~1995-08-03  4:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-08-02  4:00 grep to == vms search/window ?? The Artist
1995-08-02  4:00 ` Will Morse
1995-08-03  4:00 ` Malcolm Beattie [this message]
1995-08-10  4:00   ` Ultrix==BSD/dUnix==SysV (was :grep to == vms search/window ??) Alan Davis
read-only archive

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