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: STEVE OLLIG <sollig_at_lifetouch.com>
Date: Thu, 5 Feb 2004 12:58:17 -0600
Message-ID: <A99D178ABC11D511B46800B0D0AAE1EB0FDE090A@EXCHMN2>


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
-----------------------------------------------------------------
Received on Thu Feb 05 2004 - 12:58:17 CST

Original text of this message

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