Re: remove consecutive blank lines
- From: "gerryt@" <gerryt@xxxxxxxxx>
- Date: 21 Mar 2006 10:55:28 -0800
Harlan Grove wrote:
Gordon Elliot wrote...
Harlan Grove wrote:Ed's use of RT would work under Solaris?
Ed Morton wrote...Which, of course, won't work under Solaris.
awk -v RS= '{ORS=(RT?"\n\n":"\n");gsub(/[[:space:]]*$/,"")}NF'awk 's && /^[ \t]*$/ { print "" }; s = /[^ \t]/'
Not on nawk or /usr/xpg4/bin/awk
One True Awk compiled from source for Solaris fails also.
I don't have a Solaris account with which to test, and I'm curious
which constructs fail under Solaris's old awk. Does it not allow for
variables like s?
I'll be happy to test any scenario you provide..
s && /^[ \t]*$/ { print "" }; s = /[^ \t]/
fails under /usr/bin/awk and of course oawk
The other provided awks work fine (nawk, usr/xpg4/bin/awk)
Does it not allow multiple pattern-actions on the
same line? Does it not allow variable assignment evaluated as an
expression as a pattern? Would this also fail under Solaris's nawk or
/usr/xpg4/bin/awk? I tested it and it works under recent versions of
gawk for Windows and cygwin, mawk, GnuWin32's nawk, and Kernighan's
awk95.
Better to use Ed's idea, but to prepend a "g" to the command, to ensureIt'd only work consistently when those Solaris boxes happen to have
that it will work consistently.
gawk installed. Is that always the case?
Sometimes it is forbidden by policy (but rarely admittedly). Most of
the time
nawk could be used but the user doesnt know its there. And rarely is
/usr/xpg4/bin in the exported PATH.. I have seen cases where having
/usr/xpg4/bin before /usr/bin causing unexpected side effects as
well...
Anyway, reliance on GNU extensions isnt always the best course when
a generic solution does the same job..?
.
- References:
- remove consecutive blank lines
- From: Jeff Higgins
- Re: remove consecutive blank lines
- From: Ed Morton
- Re: remove consecutive blank lines
- From: Harlan Grove
- Re: remove consecutive blank lines
- From: Gordon Elliot
- Re: remove consecutive blank lines
- From: Harlan Grove
- remove consecutive blank lines
- Prev by Date: Re: remove consecutive blank lines
- Next by Date: How to use OFS
- Previous by thread: Re: remove consecutive blank lines
- Next by thread: Re: remove consecutive blank lines
- Index(es):
Relevant Pages
|