From: Scott Linden (sdlinden@bluebunny.com)
Date: Tue Jul 01 2003 - 14:02:41 EDT
Thanks to James Sohr and Martin Arpon for the very quick responses.
As I suspected awk was the answer. Syntax was my issue. Please see
responses below.
********************************
Hi,
The awk utility was made exactly for this purpose.
The command
awk '/start/,/stop/'
will read input from standard input, and start printing when
a line contains the string "start", and stop when a line contains the
string "stop".
The command
awk 'NR > 20 && NR < 50'
will read input from standard input, and start printing after line 20,
and stop printing at line 50.
Hope that helps,
James Sohr
*********************************
Selecting lines ranging from line 5 to line 20:
awk ' NR >= 5 && NR <= 20 {print $0}' your_file
or
your_command | awk ' NR >= 5 && NR <= 20 {print $0}'
Selecting lines after a line with the word "start-here" and till a line
with the word "finish-here":
your_command | awk ' { if (iAmIn == 1) print $0; }
/start-here/ { iAmIn = 1; }
/end-here/ { iAmIn = 0; }'
Hope it helps,
Martin
-----Original Message-----
From: Scott Linden
Sent: Tuesday, July 01, 2003 11:27 AM
To: hpux-admin@dutchworks.nl
Subject: [HPADM] Scripting Question
I am trying to write a script that will take output from a command or
parse a file to get certain information from within the output or file.
The output or file has a lot of unnecessary information and I either
need to read in the data starting at a certain line number and ending at
a certain line number or start when a line matches a given string and
ends when it matches another given string.
What is the best way to do this? Please send examples.
Thanks
Scott
-- ---> Please post QUESTIONS and SUMMARIES only!! <--- To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl Name: hpux-admin@dutchworks.nl Owner: owner-hpux-admin@dutchworks.nl Archives: ftp.dutchworks.nl:/pub/digests/hpux-admin (FTP, browse only) http://www.dutchworks.nl/htbin/hpsysadmin (Web, browse & search) -- ---> Please post QUESTIONS and SUMMARIES only!! <--- To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl Name: hpux-admin@dutchworks.nl Owner: owner-hpux-admin@dutchworks.nl Archives: ftp.dutchworks.nl:/pub/digests/hpux-admin (FTP, browse only) http://www.dutchworks.nl/htbin/hpsysadmin (Web, browse & search)
This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:31 EDT