Re: remove consecutive blank lines




Harlan Grove wrote:
Gordon Elliot wrote...
Harlan Grove wrote:
Ed Morton wrote...
awk -v RS= '{ORS=(RT?"\n\n":"\n");gsub(/[[:space:]]*$/,"")}NF'
awk 's && /^[ \t]*$/ { print "" }; s = /[^ \t]/'
Which, of course, won't work under Solaris.
Ed's use of RT would work under Solaris?

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 ensure
that it will work consistently.
It'd only work consistently when those Solaris boxes happen to have
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..?

.



Relevant Pages

  • Re: gawk for solaris
    ... Sashi wrote: ... awk failed ... I haven't used Solaris, but I've been told that in additon to nawk ...
    (comp.lang.awk)
  • Re: awk parsing records to file
    ... %> Solaris probably uses ancient awk, so use nawk (or one of the ... If you have more than 20 blocks to write out, you'll probably find nawk ... On Solaris, you'll get more standards-compliant behaviour if you put ... give you a working awk. ...
    (comp.lang.awk)
  • Re: awk substitute command doesnt work on Solaris 10 Sparc...
    ... on Solaris 10 Sparc and there appears to be a problem with it. ... anyone encounter the same issue if one uses "sub" command with ... awk and get a syntax error. ... sun came out with nawk to update it's features and capabilities. ...
    (comp.unix.solaris)
  • Re: get a word from a line matched by the preceding word..
    ... I used "nawk" and it worked. ... A search on google showed that awk on solaris is very old ...
    (comp.lang.awk)
  • Re: Using awk to remove the client port on a netstat listing
    ... > A typical netstat on my solaris provides the following output on my ... It may be faster to use both grep and awk: ... a pure shell solution could be the fastest: ...
    (comp.lang.awk)