Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sed question

44 views
Skip to first unread message

cityuk

unread,
Mar 27, 2012, 12:31:48 PM3/27/12
to
Dear All,

I have a pipeline that generates output like

file1
file2

(basically a list of files separated by newlines - od -c confirms \n
characters).

I want to join them on one line using sed (I know it can be done in a
number of other ways, just want to do it with sed).

I tried sed -e 's/^J//g' but sed came up with the message sed command
garbled (^J is Ctrl-V Ctrl-J to literally insert a newline).

How can I add the newline in the search pattern so that the sed
command will work (SunOS 5.9)?

Regards,
George

nelson

unread,
Mar 27, 2012, 6:38:25 PM3/27/12
to
see the sed FAQ,, 5.10: Why can't I match or delete a newline using
the \n escape sequence? Why can't I match 2 or more lines using \n?

http://sed.sourceforge.net/sedfaq5.html#s5.10

and use another something instead

Cydrome Leader

unread,
Mar 29, 2012, 1:09:40 AM3/29/12
to
I can't fully explain how this work, but I tested it under bsd and solaris:

sed -e :a -e '$!N;s/\n//;ta'



bash-3.00# uname -r
5.10
bash-3.00# cat >> sedtest
line1
line2
line3
line4
bash-3.00# sed -e :a -e '$!N;s/\n//;ta' sedtest
line1line2line3line4




David Combs

unread,
May 13, 2012, 10:47:09 PM5/13/12
to
In article <jl0qqj$gla$1...@reader1.panix.com>,
In emacs what I do is set fill-column to some huge number
and then do M-q (refill the paragraph -- width is
so wide (fill-column) that whole "paragraph" ends up on one (long) line.

Maybe vim also has such a command, to re "fill" a "paragraph".

And long, long ago I recall running some tool to do that -- was it "fmt",
perhaps?

David

0 new messages