<?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: sed question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563863#M725142</link>
    <description>Hi Greg:&lt;BR /&gt;&lt;BR /&gt;While I like 'tr' for this, here's another, short 'awk', given your input in a file called /tmp/myfile":&lt;BR /&gt;&lt;BR /&gt;# awk '{for (i=1;i&lt;NF&gt;&lt;/NF&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 09 Aug 2001 15:56:41 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2001-08-09T15:56:41Z</dc:date>
    <item>
      <title>sed question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563860#M725139</link>
      <description>We have a file containing multiple usernames on one line that we would like to insert returns after each username.  For example, the file would change from this:&lt;BR /&gt;&lt;BR /&gt;user1 user2 user3 user4&lt;BR /&gt;&lt;BR /&gt;to this:&lt;BR /&gt;user1&lt;BR /&gt;user2&lt;BR /&gt;user3&lt;BR /&gt;user4&lt;BR /&gt;&lt;BR /&gt;When we use the following sed command:&lt;BR /&gt;sed 's/ /\\n/g' file&lt;BR /&gt;we get this&lt;BR /&gt;user1\nuser2\nuser\nuser4&lt;BR /&gt;&lt;BR /&gt;Any ideas on how to do this, or how to make sed not look print the \n litteraly?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.</description>
      <pubDate>Thu, 09 Aug 2001 14:54:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563860#M725139</guid>
      <dc:creator>Greg Stark_1</dc:creator>
      <dc:date>2001-08-09T14:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: sed question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563861#M725140</link>
      <description>Hi Greg,&lt;BR /&gt;&lt;BR /&gt;tr " " "\012" &amp;lt; filename&lt;BR /&gt;&lt;BR /&gt;should do it.&lt;BR /&gt;&lt;BR /&gt;Robin.</description>
      <pubDate>Thu, 09 Aug 2001 15:08:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563861#M725140</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-08-09T15:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: sed question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563862#M725141</link>
      <description>Hi Greg,&lt;BR /&gt;&lt;BR /&gt;Here's one way to do it in awk.&lt;BR /&gt;&lt;BR /&gt;cat myfile | awk '{ n = split($0,arry); i = 1; while (i &amp;lt;= n) { printf("%s\n",arry[i]); ++i; } }' &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;All on one line.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards, Clay</description>
      <pubDate>Thu, 09 Aug 2001 15:20:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563862#M725141</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-08-09T15:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: sed question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563863#M725142</link>
      <description>Hi Greg:&lt;BR /&gt;&lt;BR /&gt;While I like 'tr' for this, here's another, short 'awk', given your input in a file called /tmp/myfile":&lt;BR /&gt;&lt;BR /&gt;# awk '{for (i=1;i&lt;NF&gt;&lt;/NF&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Aug 2001 15:56:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563863#M725142</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-08-09T15:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: sed question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563864#M725143</link>
      <description>How many "users" do you want per line?  You could use paste(1) like this:&lt;BR /&gt;&lt;BR /&gt;     cat file | paste - - - -&lt;BR /&gt;&lt;BR /&gt;would give you four entries per line.&lt;BR /&gt;&lt;BR /&gt;-dlt-&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Aug 2001 13:49:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563864#M725143</guid>
      <dc:creator>David Totsch</dc:creator>
      <dc:date>2001-08-10T13:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: sed question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563865#M725144</link>
      <description>While tr or awk is probably better for this, here's how it can be done with sed:&lt;BR /&gt;&lt;BR /&gt;sed 's/ //g'&lt;BR /&gt;&lt;BR /&gt;You need a literal newline - sed doesn't understand \n in the replacement part. (If your shell is csh you'll need two \s in there.)&lt;BR /&gt;&lt;BR /&gt;While at it, the shortest way to do it with awk is probably this:&lt;BR /&gt;&lt;BR /&gt;awk 1 RS=' '&lt;BR /&gt;&lt;BR /&gt;I wouldn't recommend that in production code though... (and it does result in an extra newline at the end of the file).</description>
      <pubDate>Sun, 12 Aug 2001 16:05:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563865#M725144</guid>
      <dc:creator>Tapani Tarvainen</dc:creator>
      <dc:date>2001-08-12T16:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: sed question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563866#M725145</link>
      <description>Looks like itrc system ate the backslash-newline combination in my reply. Anyway, what you need is a backslash followed by literal newline in the right-hand side of the 's' command in sed (you can have newlines inside strings).</description>
      <pubDate>Mon, 13 Aug 2001 06:53:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-question/m-p/2563866#M725145</guid>
      <dc:creator>Tapani Tarvainen</dc:creator>
      <dc:date>2001-08-13T06:53:36Z</dc:date>
    </item>
  </channel>
</rss>

