RE: HP-UX 11/grep

  • From: STEVE OLLIG <sollig@xxxxxxxxxxxxx>
  • To: "'oracle-l@xxxxxxxxxxxxx'" <oracle-l@xxxxxxxxxxxxx>
  • Date: Thu, 5 Feb 2004 12:58:17 -0600

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@xxxxxxxxxxx]
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@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //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@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------

Other related posts: