era eriksson <reriksso(_at_)cc(_dot_)helsinki(_dot_)fi> writes:
[ snip ]
> sed -e 'y/\n/|/' -e 's/\|$//'
I was unable to get any variant of this to work on two of the Unices I
tried it on (Digital/OSF1, Sun) although they choked mainly on the
newline in the y//. You are in a twisty maze of sed implementations,
all different, so your mileage may vary. The following worked on
Linux:
sed -e 'y/
/|/' -e '$s/|$//'
Everyone on this thread seems to have gotten in to a rut and
are looking at only one approach to solving the problem.
Rather than using the y operator (which I have never cared for
anyway) why not the following:
sed '$q;s/$/|/'
I can't think of a sed implementation that won't handle that.
Given the problems with sed in general, I'd be partial towards using
Perl instead;
perl -pe 'y/\n/|/; s/\|$// if eof'
This solution is essentiall the same as mine. I think that
for something this trivial perl is overkill.
[ snip ]
--
-Andrew Feren (feren(_at_)ctron(_dot_)com)
Cabletron Systems Inc.
Durham, NH