On Fri, 15 Jun 2001, Hayes, Christopher wrote:

> Looking for an example of a script that will search a file ( like a cisco
> config file )
> find a key word and then copy out "n" number of lies before or after that
> keyword.
> 
> Any help would be greatly appriciated.

You didn't say what your environment is, so I'll assume a free Unix (BSD
or Linux).

% man grep

SYNOPSIS
       grep  [-[AB]  num] [-HRPS] [-CEFGLVabchilnqsvwx] [-e expr]
       [-f file] files...
...
       -num   Matches will be printed with num lines  of  leading
              and  trailing  context.   However,  grep will never
              print any given line more than once.
       -A num Print num lines of trailing context after  matching
              lines.
       -B num Print  num lines of leading context before matching
              lines.
       -C     Equivalent to -2.

Options appear to be present in FreeBSD, NetBSD, and Linux versions of
grep.

-- 
"Someone approached me and asked me to teach a javascript course. I was
about to decline, saying that my complete ignorance of the subject made
me unsuitable, then I thought again, that maybe it doesn't, as driving
people away from it is a desirable outcome." --Me




Message Posted at:
http://www.groupstudy.com/form/read.php?f=7&i=8779&t=8761
--------------------------------------------------
FAQ, list archives, and subscription info: http://www.groupstudy.com/list/cisco.html
Report misconduct and Nondisclosure violations to [EMAIL PROTECTED]

Reply via email to