<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Join lines into one line in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774955#M640696</link>
    <description>&lt;!--!*#--&gt;&amp;gt; # awk '{printf $0","} END {print}' file.txt&lt;BR /&gt;&lt;BR /&gt;Around here, that still has the extra comma&lt;BR /&gt;at the end:&lt;BR /&gt;&lt;BR /&gt;dyi # awk '{printf $0","} END {print}' file.txt&lt;BR /&gt;line 1,line 2,line 3,&lt;BR /&gt;&lt;BR /&gt;(But it does better with embedded spaces.)</description>
    <pubDate>Thu, 07 Apr 2011 13:17:49 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2011-04-07T13:17:49Z</dc:date>
    <item>
      <title>Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774947#M640688</link>
      <description>Hi, &lt;BR /&gt;&lt;BR /&gt;I have a text file which includes undefined number of lines as follows:&lt;BR /&gt;====file.txt====&lt;BR /&gt;line1&lt;BR /&gt;line2&lt;BR /&gt;line3&lt;BR /&gt;line4&lt;BR /&gt;[...]&lt;BR /&gt;lineN&lt;BR /&gt;============&lt;BR /&gt;&lt;BR /&gt;What command should I use to have the output like that:&lt;BR /&gt;line1,line2,line3,line4,[...],lineN&lt;BR /&gt;&lt;BR /&gt;awk is very welcome. Thanks in advance&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Apr 2011 12:20:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774947#M640688</guid>
      <dc:creator>wojtek75</dc:creator>
      <dc:date>2011-04-07T12:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774948#M640689</link>
      <description>tr '\n' ',' &amp;lt; file.txt&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Thu, 07 Apr 2011 12:38:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774948#M640689</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2011-04-07T12:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774949#M640690</link>
      <description>&lt;!--!*#--&gt;&amp;gt; tr '\n' ',' &amp;lt; file.txt&lt;BR /&gt;&lt;BR /&gt;And, to trim off the final comma:&lt;BR /&gt;&lt;BR /&gt;      &amp;lt; file.txt tr '\n' ',' | sed -e 's/,$//'</description>
      <pubDate>Thu, 07 Apr 2011 12:47:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774949#M640690</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-04-07T12:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774950#M640691</link>
      <description>or&lt;BR /&gt;&lt;BR /&gt;# cat file.txt | xargs</description>
      <pubDate>Thu, 07 Apr 2011 12:48:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774950#M640691</guid>
      <dc:creator>Viktor Balogh</dc:creator>
      <dc:date>2011-04-07T12:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774951#M640692</link>
      <description>xargs uses space ' ' instead of comma.</description>
      <pubDate>Thu, 07 Apr 2011 12:49:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774951#M640692</guid>
      <dc:creator>wojtek75</dc:creator>
      <dc:date>2011-04-07T12:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774952#M640693</link>
      <description>.. if you want it comma-separated:&lt;BR /&gt;&lt;BR /&gt;# cat file.txt | xargs | tr " " ","&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Apr 2011 12:49:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774952#M640693</guid>
      <dc:creator>Viktor Balogh</dc:creator>
      <dc:date>2011-04-07T12:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774953#M640694</link>
      <description>&amp;gt; awk is very welcome. Thanks in advance&lt;BR /&gt;&lt;BR /&gt;here is your AWKward solution:&lt;BR /&gt;&lt;BR /&gt;# awk '{printf $0","} END {print}' file.txt&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Apr 2011 13:11:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774953#M640694</guid>
      <dc:creator>Viktor Balogh</dc:creator>
      <dc:date>2011-04-07T13:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774954#M640695</link>
      <description>&lt;!--!*#--&gt;&amp;gt; # cat file.txt | xargs | tr " " ","&lt;BR /&gt;&lt;BR /&gt;Not so good if the lines contain spaces:&lt;BR /&gt;&lt;BR /&gt;dyi # cat file.txt&lt;BR /&gt;line 1&lt;BR /&gt;line 2&lt;BR /&gt;line 3&lt;BR /&gt;&lt;BR /&gt;dyi # cat file.txt | xargs | tr " " ","&lt;BR /&gt;line,1,line,2,line,3&lt;BR /&gt;&lt;BR /&gt;But (this time on a real HP-UX system):&lt;BR /&gt;&lt;BR /&gt;dyi # ( tr '\n' ',' ; echo '' ) &amp;lt; file.txt | sed -e 's/,$//'&lt;BR /&gt;line 1,line 2,line 3&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;(Some "sed" programs don't do well with&lt;BR /&gt;unterminated lines, I see.  Everything's&lt;BR /&gt;complicated.)</description>
      <pubDate>Thu, 07 Apr 2011 13:14:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774954#M640695</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-04-07T13:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774955#M640696</link>
      <description>&lt;!--!*#--&gt;&amp;gt; # awk '{printf $0","} END {print}' file.txt&lt;BR /&gt;&lt;BR /&gt;Around here, that still has the extra comma&lt;BR /&gt;at the end:&lt;BR /&gt;&lt;BR /&gt;dyi # awk '{printf $0","} END {print}' file.txt&lt;BR /&gt;line 1,line 2,line 3,&lt;BR /&gt;&lt;BR /&gt;(But it does better with embedded spaces.)</description>
      <pubDate>Thu, 07 Apr 2011 13:17:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774955#M640696</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-04-07T13:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774956#M640697</link>
      <description>&amp;gt; Around here, that still has the extra comma&lt;BR /&gt;at the end&lt;BR /&gt;&lt;BR /&gt;nope, on my linux box it duplicates the last line and so I didn't end up with an extra comma. I just didn't recognize the duplicate.&lt;BR /&gt;&lt;BR /&gt;basically I wanted this version, but somehow the reference to the last line didn't work:&lt;BR /&gt;&lt;BR /&gt;# awk 'NR != "$NR" {printf $0","} END {print}' test&lt;BR /&gt;&lt;BR /&gt;so I ended up with this:&lt;BR /&gt;&lt;BR /&gt;# awk '!(NR-1) {printf $0} NR-1 {printf ","$0} END {print ""}'&lt;BR /&gt;&lt;BR /&gt;which works on linux. (too sad I don't have an HP-UX access at the moment :(&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Apr 2011 13:31:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774956#M640697</guid>
      <dc:creator>Viktor Balogh</dc:creator>
      <dc:date>2011-04-07T13:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774957#M640698</link>
      <description>I know this horse has been beaten but here is how I would deal with the 'extra comma' problem in awk:&lt;BR /&gt;&lt;BR /&gt;$ awk '{printf comma $0; comma=","}'  x.txt&lt;BR /&gt;&lt;BR /&gt;so we print a comma BEFORE each fresh line, but we don't want one on the first line, so we set a symbol to the value comma, after the first print.&lt;BR /&gt;(and again and again, but awk don't mind that :-).&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Apr 2011 04:47:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774957#M640698</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2011-04-08T04:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774958#M640699</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;#AUX=`cat file.txt|tr "\n" ","`&lt;BR /&gt;#echo $AUX &amp;gt; file.aux&lt;BR /&gt;#cat file.aux&lt;BR /&gt;line1,line2,line3,line4,...,&lt;BR /&gt;&lt;BR /&gt;Rgds.</description>
      <pubDate>Fri, 08 Apr 2011 08:57:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774958#M640699</guid>
      <dc:creator>Jose Mosquera</dc:creator>
      <dc:date>2011-04-08T08:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Join lines into one line</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774959#M640700</link>
      <description>Hein,&lt;BR /&gt;&lt;BR /&gt;&amp;gt;so we print a comma BEFORE each fresh line, but we don't want one on the first line&lt;BR /&gt;&lt;BR /&gt;that's exactly what I did with &lt;BR /&gt;&lt;BR /&gt;# awk '!(NR-1) {printf $0} NR-1 {printf ","$0} END {print ""}'&lt;BR /&gt;&lt;BR /&gt;but you solution is genious! Maybe an END section just to echo a linefeed after the last line... ;)</description>
      <pubDate>Fri, 08 Apr 2011 09:41:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/join-lines-into-one-line/m-p/4774959#M640700</guid>
      <dc:creator>Viktor Balogh</dc:creator>
      <dc:date>2011-04-08T09:41:47Z</dc:date>
    </item>
  </channel>
</rss>

