[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Text formatting
On Tue, Jun 04, 2002 at 07:27:28PM -0500, Jason Smith wrote:
> What would be the easiest way to string 3 lines of text and make it into
> one line. What I have is a page of text with 3 line blocks of text that
> I want to make into one line so that I can feed it into an awk script.
perl -e 'while (<>) { tr/\n/ / if ($. % 3); print; }'
Or just
perl -pe 'tr/\n/ / if ($. % 3)'
Something like that?
The same thing is pretty trivial in awk. (There may even be an easier
way than this. I'm not that good with awk.)
awk '{ if (FNR % 3) { ORS=" " } else { ORS="\n" } print }'
Steve
--
steve@silug.org | Southern Illinois Linux Users Group
(618)398-7360 | See web site for meeting details.
Steven Pritchard | http://www.silug.org/
-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.