Path: utzoo!attcan!uunet!seismo!esosun!cogen!alen
From: alen@cogen.UUCP (Alen Shapiro)
Newsgroups: comp.unix.questions
Subject: a "trivial" sed question
Summary: can sed join all lines?
Message-ID: <512@cogen.UUCP>
Date: 6 Jun 88 22:22:59 GMT
Reply-To: alen@cogen.UUCP (Alen Shapiro)
Organization: Cogensys, LaJolla, Calf.
Lines: 41

I know the answer is 'use tr -d "\012"' but here is the question;

Is there a way USING SED to remove all  chars from a file. This is
just an exercise since "tr" provides the functionality but it was
part of a question that a student asked me and I was unable to give
a satifactory answer. The effect I want to see can be emulated by
2 sed commands

1) 'N' - add next line to current pattern space
2) 's/\n//g'

But I only get what I want if I repeat 'N'  times on the first line
of the script (where  is the number of lines in the input file - not
very satisfactory).

The closest I got was to make a script that joins every second line!!

: l
N
s/\n/ /
t l

I have managed to crash "sed -n" with a core dump with this effort...
(sed{0,1}.c 1.1 86/07/07 SMI)

: b
N
s/\n/ /g
H
t b
g
s/\n/ /g
p

which just goes to show how convoluted my reasoning became before giving up.
I bet you guys and gals can think of a really easy solution.


--alen the Lisa slayer (it's a long story)

    ...!{seismo,esosun,suntan}!cogen!alen