* trailing newlines
@ 1992-04-17 18:18 Arnold D. Robbins
0 siblings, 0 replies; 2+ messages in thread
From: Arnold D. Robbins @ 1992-04-17 18:18 UTC (permalink / raw)
To: rc
OK, here's another try, (tested, even!):
x = '
string
with lots
of
embedded newlines
'
gawk '
{
if (! first)
print save
else
first = 1
save = $0
}
END { printf ("%s", save) }' <<< $x
Your luck with other awks may vary, particularly when processing
binary data; I have much higher confidence in gawk in that regard.
Arnold
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: trailing newlines
@ 1992-04-18 15:05 malte
0 siblings, 0 replies; 2+ messages in thread
From: malte @ 1992-04-18 15:05 UTC (permalink / raw)
To: rc
I'm not sure if I get the point, but isn't this what you want:
x = `` ($nl) { echo $x } # strips all newlines
or
fn deletenl {
* = `` ($nl) { echo $* }
while ( ! ~ $#* 0 1 ){ # echo all args but the last
echo $^1
shift
}
echo -n `` ($nl) { echo $^1 } # echo last arg without nl
}
x = `` () { deletenl $x }
To be honest, deletenl squeezes repeated nls into one.
Malte.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1992-04-18 15:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-04-17 18:18 trailing newlines Arnold D. Robbins
1992-04-18 15:05 malte
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).