Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!lll-winken!ncis.tis.llnl.gov!blackbird!hamlin From: hamlin@blackbird.afit.af.mil (Joe Hamlin) Newsgroups: comp.unix.questions Subject: Re: removing end of line mark with sed Message-ID: <1681@blackbird.afit.af.mil> Date: 20 Aug 90 04:11:01 GMT References: <1990Aug19.194911.16628@fs-1.iastate.edu> <1990Aug19.234327.19785@iwarp.intel.com> Organization: Air Force Institute of Technology; WPAFB, OH Lines: 47 merlyn@iwarp.intel.com (Randal Schwartz) writes: >In article <1990Aug19.194911.16628@fs-1.iastate.edu>, spam@hobbes (Begley Michael L) writes: >| [How to turn]: >| 1 >| 2 >| 3 >| into: >| 1 2 3 >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 Don't know about "proper", but this seems to work: sed -n -e '1{;h;$p;b' -e '}' -e 'H;$x;$s/\n/ /gp' Seems a bit ugly, though. It's not absolutely clear from the problem, how many spaces/tabs are wanted as separator(s), or whether or not a trailing newline is required. Add spaces to taste. >tr '\012' ' ' >instead of sed. If you really need the trailing newline, and you have >a shell with a builtin echo, try: >[Randal's echo script] or: (tr '\012' ' '; echo) or: >echo `some_command_that_produces_those_lines` Both the tr and single line echo solutions are limited to a single space separator. >perl -pe 's/\n/ / unless eof;' It's even readable. :-) And in awk: awk '{printf "%s ", $0} END {print}' -- Joe Hamlin