Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!umich!samsung!zaphod.mps.ohio-state.edu!mips!decwrl!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.unix.questions Subject: Re: removing end of line mark with sed Message-ID: <1990Aug19.234327.19785@iwarp.intel.com> Date: 19 Aug 90 23:43:27 GMT References: <1990Aug19.194911.16628@fs-1.iastate.edu> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 46 In-Reply-To: spam@hobbes.cc.iastate.edu (Begley Michael L) In article <1990Aug19.194911.16628@fs-1.iastate.edu>, spam@hobbes (Begley Michael L) writes: | Here's a simple one... | How do I remove the end of line marker from a stream? for example, | if I have a stream that esentially looks like: | 1 | 2 | 3 | how do I make it into: | 1 2 3 | | I tried sed 's/\n//' but that didn't work. Thanks. I horsed around with the 'N' command in sed, thinking I could make it do that, and figured out that I had lost the sed touch. (Somebody will most certainly post the proper way to do it.) Try tr '\012' ' ' instead of sed. If you really need the trailing newline, and you have a shell with a builtin echo, try: ...some_command | some_command_that_produces_those_lines | while read x do echo -n "$x " done echo "" or echo `some_command_that_produces_those_lines` depending on how you get your data. The first one is *really* expensive if you don't have a builtin echo, but the second one isn't bad. Obligatory Perl reference: perl -pe 's/\n/ / unless eof;' Just another (former) sed user, -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/