<?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: grouping data using awk in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138851#M317320</link>
    <description>&lt;!--!*#--&gt;myoutput=$(echo $a | awk '&lt;BR /&gt;function trans(ins) {&lt;BR /&gt;if (ins == 1)&lt;BR /&gt;   return "INTERIM"&lt;BR /&gt;else if (ins == 2)&lt;BR /&gt;   return "PERMANENT"&lt;BR /&gt;return ins  # error case?&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;out = trans($1)&lt;BR /&gt;for (k=2;k&amp;lt;=NF;k++) {&lt;BR /&gt;  out=sprintf("%s,%s",out,trans($k))&lt;BR /&gt;}&lt;BR /&gt;print out&lt;BR /&gt;}')</description>
    <pubDate>Fri, 01 Feb 2008 11:12:41 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2008-02-01T11:12:41Z</dc:date>
    <item>
      <title>grouping data using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138850#M317319</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I am trying to group data present in one variable.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;i am using below code:&lt;BR /&gt;&lt;BR /&gt;myoutput=`echo $a | awk '{out=$1;for (k=2;k&amp;lt;=NF;k++){out=sprintf("%s,%s",out,$k);}print out}'`&lt;BR /&gt;&lt;BR /&gt;value of var a is:&lt;BR /&gt;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;my output is:&lt;BR /&gt;&lt;BR /&gt;echo $myoutput&lt;BR /&gt;1,2,1,2&lt;BR /&gt;&lt;BR /&gt;**************************************&lt;BR /&gt;Now here i want to put one condition in awk that:&lt;BR /&gt;&lt;BR /&gt;if $k = 1 then&lt;BR /&gt;$out="INTERIM"&lt;BR /&gt;&lt;BR /&gt;if $k = 2 then&lt;BR /&gt;$out="PERMANENT"&lt;BR /&gt;&lt;BR /&gt;hence my out put should be like:&lt;BR /&gt;&lt;BR /&gt;echo $myoutput&lt;BR /&gt;INTERIM,PERMANENT,INTERIM,PERMANENT&lt;BR /&gt;&lt;BR /&gt;Could some pelase suggest how to make this changes?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Feb 2008 08:43:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138850#M317319</guid>
      <dc:creator>N Gopal</dc:creator>
      <dc:date>2008-02-01T08:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: grouping data using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138851#M317320</link>
      <description>&lt;!--!*#--&gt;myoutput=$(echo $a | awk '&lt;BR /&gt;function trans(ins) {&lt;BR /&gt;if (ins == 1)&lt;BR /&gt;   return "INTERIM"&lt;BR /&gt;else if (ins == 2)&lt;BR /&gt;   return "PERMANENT"&lt;BR /&gt;return ins  # error case?&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;out = trans($1)&lt;BR /&gt;for (k=2;k&amp;lt;=NF;k++) {&lt;BR /&gt;  out=sprintf("%s,%s",out,trans($k))&lt;BR /&gt;}&lt;BR /&gt;print out&lt;BR /&gt;}')</description>
      <pubDate>Fri, 01 Feb 2008 11:12:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138851#M317320</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-02-01T11:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: grouping data using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138852#M317321</link>
      <description>Hi Dennis,&lt;BR /&gt;&lt;BR /&gt;Many thanks, It seems that it is working.&lt;BR /&gt;&lt;BR /&gt;One clarification:&lt;BR /&gt;&lt;BR /&gt;in your code what is the use of :&lt;BR /&gt;return ins  # error case? line&lt;BR /&gt;Shall i remove this? Is it have any impact?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Fri, 01 Feb 2008 11:43:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138852#M317321</guid>
      <dc:creator>N Gopal</dc:creator>
      <dc:date>2008-02-01T11:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: grouping data using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138853#M317322</link>
      <description>&amp;gt;in your code what is the use of:&lt;BR /&gt;return ins # error case? line&lt;BR /&gt;&amp;gt;Shall i remove this? Is it have any impact?&lt;BR /&gt;&lt;BR /&gt;If you want to change "k" only for 1 or 2, you need that assignment to leave it unchanged.  So you should change the comment.</description>
      <pubDate>Fri, 01 Feb 2008 11:49:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138853#M317322</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-02-01T11:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: grouping data using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138854#M317323</link>
      <description>Hi Dennis,&lt;BR /&gt;&lt;BR /&gt;I am going to use for only 1 or 2. There will be no values other than 1 or 2.&lt;BR /&gt;&lt;BR /&gt;So shall i leave it as it is?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Fri, 01 Feb 2008 12:28:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138854#M317323</guid>
      <dc:creator>N Gopal</dc:creator>
      <dc:date>2008-02-01T12:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: grouping data using awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138855#M317324</link>
      <description>&lt;!--!*#--&gt;&amp;gt;I am going to use for only 1 or 2. There will be no values other than 1 or 2.&lt;BR /&gt;&amp;gt;So shall i leave it as it is?&lt;BR /&gt;&lt;BR /&gt;You might as well, even the comment.  That suggests how you can extend the function.  Otherwise you could optimize it as:&lt;BR /&gt;if (ins == 1)&lt;BR /&gt;   return "INTERIM"&lt;BR /&gt;else&lt;BR /&gt;   return "PERMANENT"</description>
      <pubDate>Fri, 01 Feb 2008 12:38:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/grouping-data-using-awk/m-p/4138855#M317324</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-02-01T12:38:26Z</dc:date>
    </item>
  </channel>
</rss>

