HP3000-L Archives

January 2002, Week 5

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Ken Hirsch <[log in to unmask]>
Reply To:
Ken Hirsch <[log in to unmask]>
Date:
Tue, 29 Jan 2002 15:57:15 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (23 lines)
[log in to unmask] wrote:
> followed by new lines. I thought it would be a simple matter to find space
> 2\n\n\n, and replace with space 2\n\n\n\n:
> perl -pi -e 's/  2\n\n\n/  2\n\n\n\n/' FILENAME
>
> And it's not working. And I am not sure why it is not working. Can someone
> tell me why not, and what would work, instead?

perl -p only reads one line at a time, so you're never going to match "\n\n"
that way.

If the file isn't too huge (i.e. can fit in memory), you can do this:

perl -e 'undef $/;  $_ = <>; s/  2\n\n\n/  2\n\n\n\n/g; print' FILENAME
>NEWFILE

Otherwise, you'll have to actually write a program of 5-20 lines.

Ken

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2