|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
grep for group of lines
Unix guru,
How do I grep a file for "REB" so the output shows the 3 lines above and below each "REB" line (including "REB" line)? I used to have a simple grep/sed/awk to do it but I lost it. I thought it used grep and tail, but so far my attempts don't work. Thanks, Ron |
|
#2
|
|||
|
|||
|
not that I consider myself a guru, but this is easy enough to clear up ...
read the manpage for grep. Those are the first few options listed: Code:
man grep -B (efore) -A (fter) -Steven __________________ You ride a horse rather less well than another horse would. –Edmund Black Adder |
|
#3
|
|||
|
|||
|
Steve,
I checked man page for /usr/bin/grep and /usr/xpg4/bin/grep on SunOS5.8. They don't support -B and -A??? Thanks, Ron |
|
#4
|
|||
|
|||
|
yes ron A|B are on solaris not supported, maybe is this a gnu grep.
not very easy. if you always have exactly 3lines below and 3lines after, split -7 can be an approach, else read in awk|perl|c the whole file in an array ... |
|
#5
|
|||
|
|||
|
ouch! ..ok. I don't have solaris running anywhere anymore.
-Steven |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > grep for group of lines |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|