[TAG] Using defined egrep
Ben Okopnik
ben at callahans.org
Fri May 7 23:42:42 MSD 2004
On Fri, May 07, 2004 at 03:31:48PM +0100, Thomas Adam wrote:
> --- Aramico <aramico at aramico.duahati.com> wrote:
>
> > Friends, its me Aramico,
> > .. and I have an important case to be resolve,
> > hope that you can help me.
>
> Certainly, Watson, we must hurry. We might just be in time for the 18:02
> train to Colchester.
The fact that Aramico used HTML - completely ignoring the TAG guidelines
stated in "Asking Questions of The Answer Gang" at
<http://linuxgazette.net/tag/ask-the-gang.html> - tells me that he's
*not* in a hurry; otherwise, he'd have asked as politely as possible,
which violating the guidelines is emphatically not.
However, we'll give this a shot anyway, in the hope that he will realize
his mistake and come around...
> > How can I use egrep to produced information such as 4 lines above and 4
> > lines under the word that i've defined ?
> > What I mean is if im using egrep for the word 21-777, the output as i
> > need must be egreped word with 4 lines above egreped and 4 lines under
> > egraped word.
[snip]
> [n6tadam at station tmp]$ egrep -B4 'match' ./test
[snap]
> [n6tadam at station tmp]$ egrep -A4 'match' ./test
[snippety-do-dah]
> [n6tadam at station tmp]$ egrep -A4 -B4 'match' ./test
Plain old "grep" ("egrep", at least on Debian, is nothing more than a
shell script executing 'grep -E ${1+$@}') will do this just fine if you
skip the "before" and "after" qualifiers:
# Give me three lines to either side of the match.
grep -3 'match' test
"egrep" would, of course, do exactly the same thing, since no extended
regex (that being what the "e" stands for) is being used.
* Ben Okopnik * okopnik.freeshell.org * Technical Editor, Linux Gazette *
-*- See the Linux Gazette in its new home: <http://linuxgazette.net/> -*-
More information about the TAG
mailing list