[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: awk



 > From: Leonid Leibman <http://www.raqia.com/~leonidl>
 > Date: Thu, 29 Nov 2001 14:33:26 -0500
 >
 > Hi, Robert -- do you know whether there is a way to make gawk understand \n?
 > Suppose I have a file which contains lines separated by \n (newline) and 
 > I want to match
 > certain patterns regardless whether they are more than one line long. 
 > For example
 > I have a file containing 2 lines of aa-s:
 > 
 > aa
 > aa
 > 
 > and I want to match a pattern '/aa\012aa/ {print $1}'
 > 
 > Is there a way to do this????


You probably cannot put the newline right in the pattern itself.  Probably
you'll have to do something like:

/aa/{if (lastaa) { print "success"; } lastaa=1; }
/aa/! { lastaa=0; }

I have no idea whether this would work.  I'd just write it in Perl :-).









Why do you want this page removed?