grep awk example script


What is this stuff?

If this isn't exactly what you wanted, please try our Search (there's a LOT of techy and non-techy stuff here about Linux, Unix, Mac OS X and just computers in general!):



From - Fri Jun 16 07:27:48 2000 Message-ID: <3945CF25.F79F60DE@idealgroup.com>
Date: Mon, 12 Jun 2000 23:05:25 -0700
From: Darryl Krasman <darryl@idealgroup.com>
Organization: Ideal Computer Group Inc.
X-Mailer: Mozilla 4.7 [en] (X11; I; SCO_SV 3.2 i386)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.unix.sco.misc
Subject: Re: Newbie grep question References: <m131cNG-000CnpC@egps.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: sparky.idealgroup.com
X-Trace: 12 Jun 2000 23:03:03 -0800, sparky.idealgroup.com
Lines: 41
Path: news.randori.com!hermes.visi.com!news-out.visi.com!upp1.onvoy!msc1.onvoy!onvoy.com!sunqbc.risq.qc.ca!cyclone.bc.net!newsfeed.bc.tac.net!news.vphos.net!sparky.idealgroup.com
Xref: news.randori.com comp.unix.sco.misc:61649
X-Mozilla-Status: 8010
X-Mozilla-Status2: 00000000


Hate these ads?




Nachman Yaakov Ziskind wrote:

> ... any easy way to sed/awk/grep out the line AFTER the marker line?
> I.e., I have text like this:

> junk
> junk
> MARK
> I want this line
> junk
> junk
> junk
> MARK
> I want this line
> junk
> junk
> MARK
> I want this line
> junk
> junk
> junk
> junk
> MARK
> I want this line
> MARK
> I want this line

> and so forth? No particular patterns/line counts to rely on - just the
> presence of "MARK" lets me know that the next line is valuable.  I spent some
> time reading man pages, and managed to hit
> MEGO. :-(

> SCO OSE 505

> Thanks!



Assuming your data is in a file called "data" try this:
$ awk '/^MARK/ { OK = 1; continue } OK == 1 { print $0; OK = 0 }' data
-- 
Darryl
Ideal Computer Group Inc.
















Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them.

I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.




Comments


Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments

If you want a picture to show with your comment, go get a Gravatar


Versatile Site Map Generator $49.00
A1 Sitemap Generator


/Bofcusm/385.html copyright 1997-2004 (various authors) All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here


book graphic unix and linux troubleshooting guide

My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!





More:
       - Newsgroup




Related Posts

Xargs test question

How do I recursively grep through sub directories?

Wrapping scripts

How do I solve an "arglist too long"?

grep and ps

Xargs

Grep -d --recurse

Xargs test question

Grep in Depth










Change Congress