a "trivial" sed question
Alen Shapiro
alen at cogen.UUCP
Tue Jun 7 08:22:59 AEST 1988
I know the answer is 'use tr -d "\012"' but here is the question;
Is there a way USING SED to remove all <NL> 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' <x> times on the first line
of the script (where <x> 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
More information about the Comp.unix.questions
mailing list