Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Sep 2009 08:50:58 +0200
From:      Jonathan McKeown <j.mckeown@ru.ac.za>
To:        freebsd-questions@freebsd.org
Subject:   Re: remove newlines from a file
Message-ID:  <200909020850.58967.j.mckeown@ru.ac.za>

next in thread | raw e-mail | index | archive | help
[Arrrrgghh. To list this time]

On Tuesday 01 September 2009 20:03:19 Paul Schmehl wrote:
> I found a sed tutorial once that did this, but I can't seem to find it
> again. I have a file with multiple lines, each of which contains a single
> ip followed by a /32 and a comma.  I want to combine all those lines into a
> single line by removing all the newline characters at the end of each line.
>
> What's the best/most efficient way of doing that in a shell?

I'd use rs(1).

<inputfile rs -C\

(The \ is escaping a space delimiter.)

unless I was worried about maximum length of output lines, in which case

<inputfile xargs

Jonathan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909020850.58967.j.mckeown>