Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: HP-UX 11/grep

RE: HP-UX 11/grep

From: <Jared.Still_at_radisys.com>
Date: Thu, 5 Feb 2004 11:37:07 -0800
Message-ID: <OF41B0037E.BE2852E4-ON88256E31.006BA41C-88256E31.006BB3F7@radisys.com>


nothing wrong with the perl.
You might consider getting gnu grep though.

grep -3 string file

This will display the 3 lines before/after the target string.

STEVE OLLIG <sollig_at_lifetouch.com>
Sent by: oracle-l-bounce_at_freelists.org
 02/05/2004 10:58 AM
 Please respond to oracle-l  

        To:     "'oracle-l_at_freelists.org'" <oracle-l_at_freelists.org>
        cc: 
        Subject:        RE: HP-UX 11/grep


your fond memories are of the VMS command search/window=n

i also needed something similar on solaris recently and resorted to a simple
perl script. i also considered awk.

hopefully Jared won't laugh at my admitted rusty perl skills. the code below finds a line containing "string" in /path/file and will print that line and the one following to stdout. granted it could easily be more re-usable and window lines on both sides of "string" like the old VMS command did, but i was in a hurry and had a very specific application for this...

<snip>
#!/bin/perl -w

use strict;

my $log_file = '/path/file';
my $printnext = 'no';

open(LOG, "<$log_file") or die "Couldn't open file $log_file: $!";

while (<LOG>) {
  if ( $printnext eq "yes" ) {
    print("$_\n");
}

  $printnext = 'no';
  if ( /string/ ) {
    print("$_\n");
    $printnext = 'yes';
}

}
close(LOG) or die "Couldn't close file $log_file: $!"; </snip>

-----Original Message-----
From: Vergara, Michael (TEM) [mailto:mvergara_at_guidant.com] Sent: Thursday, February 05, 2004 12:43 PM To: Oracle-L (E-mail)
Subject: OT: HP-UX 11/grep

Hi Gang...sorry about being kinda OT...but...

A long time ago, when I used VMS, I could scan a file and see a set number of lines before and after the line I was looking=20 for. I don't even remember the command nowadays.

Does anyone know of an analogous command that can be used in the *NIX environment?

Thanks,
Mike

---
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=

Michael P. Vergara
Oracle DBA
Guidant Corporation

----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request_at_freelists.org
put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request_at_freelists.org
put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------




----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request_at_freelists.org
put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
Received on Thu Feb 05 2004 - 13:37:07 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US