<?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: how to reformat flat file using cut command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-reformat-flat-file-using-cut-command/m-p/4697182#M659119</link>
    <description>The pipe character is a rather evil separator in shell.  Lots of ways to do anything on unix.  Call this one the shell IFS example:&lt;BR /&gt;&lt;BR /&gt;# convertStuff() {&lt;BR /&gt;-&amp;gt; IFS="#"&lt;BR /&gt;-&amp;gt;&lt;BR /&gt;-&amp;gt; for X in "${@}"&lt;BR /&gt;-&amp;gt; do&lt;BR /&gt;-&amp;gt;   echo $X&lt;BR /&gt;-&amp;gt; done&lt;BR /&gt;-&amp;gt; }&lt;BR /&gt;# convertStuff $( cat file | sed -e "s/\|/#/g" )&lt;BR /&gt;1;20101009;50791.00&lt;BR /&gt;2;20101009;698.77&lt;BR /&gt;3;20290309;862655.00&lt;BR /&gt;4;20290309;454646.00&lt;BR /&gt;5;20290309;94.00&lt;BR /&gt;10;20101005;0.00&lt;BR /&gt;11;20101103;0.00&lt;BR /&gt;15;20291112;47.00&lt;BR /&gt;16;20291203;55.00&lt;BR /&gt;17;20101017;0.00&lt;BR /&gt;&lt;BR /&gt;Using that trick a pure sh solution is an easy exercise for the reader...&lt;BR /&gt;&lt;BR /&gt;Bets on time until a Perl solution is posted and who does it?  :-)&lt;BR /&gt;</description>
    <pubDate>Fri, 08 Oct 2010 15:38:32 GMT</pubDate>
    <dc:creator>Bob E Campbell</dc:creator>
    <dc:date>2010-10-08T15:38:32Z</dc:date>
    <item>
      <title>how to reformat flat file using cut command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-reformat-flat-file-using-cut-command/m-p/4697181#M659118</link>
      <description>&lt;!--!*#--&gt;Hi &lt;BR /&gt;&lt;BR /&gt;today I got some new requirement ,I am not able to get the solution for this using&lt;BR /&gt;awk or cut command please help me.&lt;BR /&gt;&lt;BR /&gt;Problem: I have given sample input file below,&lt;BR /&gt;&lt;BR /&gt;I/p file&lt;BR /&gt;-------------------------------------------&lt;BR /&gt;9029774138: "B2", 1;20101009;50791.00|2;20101009;698.77|3;20290309;862655.00|4;20290309;454646.00|&lt;BR /&gt;5;20290309;94.00|10;20101005;0.00|11;20101103;0.00|15;20291112;47.00|16;20291203;55.00|&lt;BR /&gt;17;20101017;0.00&lt;BR /&gt;Required output file&lt;BR /&gt;---------------------------&lt;BR /&gt;9029774138:"B2":10:1,2,3,4,5,10,11,15,16,17&lt;BR /&gt;--------------------------------------------&lt;BR /&gt;out put is a colon seperated file first two fields are same as first two fields in input file, third record is the count (number of pipe symbols + 1) fourth record is string seperated by comma which contains each field after the pipe symbol .&lt;BR /&gt;&lt;BR /&gt;Thanks in Anticipation&lt;BR /&gt;Gopi</description>
      <pubDate>Fri, 08 Oct 2010 15:04:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-reformat-flat-file-using-cut-command/m-p/4697181#M659118</guid>
      <dc:creator>Gopi Kishore m</dc:creator>
      <dc:date>2010-10-08T15:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to reformat flat file using cut command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-reformat-flat-file-using-cut-command/m-p/4697182#M659119</link>
      <description>The pipe character is a rather evil separator in shell.  Lots of ways to do anything on unix.  Call this one the shell IFS example:&lt;BR /&gt;&lt;BR /&gt;# convertStuff() {&lt;BR /&gt;-&amp;gt; IFS="#"&lt;BR /&gt;-&amp;gt;&lt;BR /&gt;-&amp;gt; for X in "${@}"&lt;BR /&gt;-&amp;gt; do&lt;BR /&gt;-&amp;gt;   echo $X&lt;BR /&gt;-&amp;gt; done&lt;BR /&gt;-&amp;gt; }&lt;BR /&gt;# convertStuff $( cat file | sed -e "s/\|/#/g" )&lt;BR /&gt;1;20101009;50791.00&lt;BR /&gt;2;20101009;698.77&lt;BR /&gt;3;20290309;862655.00&lt;BR /&gt;4;20290309;454646.00&lt;BR /&gt;5;20290309;94.00&lt;BR /&gt;10;20101005;0.00&lt;BR /&gt;11;20101103;0.00&lt;BR /&gt;15;20291112;47.00&lt;BR /&gt;16;20291203;55.00&lt;BR /&gt;17;20101017;0.00&lt;BR /&gt;&lt;BR /&gt;Using that trick a pure sh solution is an easy exercise for the reader...&lt;BR /&gt;&lt;BR /&gt;Bets on time until a Perl solution is posted and who does it?  :-)&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Oct 2010 15:38:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-reformat-flat-file-using-cut-command/m-p/4697182#M659119</guid>
      <dc:creator>Bob E Campbell</dc:creator>
      <dc:date>2010-10-08T15:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to reformat flat file using cut command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-reformat-flat-file-using-cut-command/m-p/4697183#M659120</link>
      <description>&lt;!--!*#--&gt;to 'walk' the list you'll have to write a little program  in the language of your choice.&lt;BR /&gt;C, shell, perl, awk.&lt;BR /&gt;&lt;BR /&gt;Using AWK, the following seems to work:&lt;BR /&gt;&lt;BR /&gt;---------- test.awk --------&lt;BR /&gt;{ &lt;BR /&gt;values = split ($3, a, "|");&lt;BR /&gt;line = $1  $2 values ":";&lt;BR /&gt;for (i = 1; i &amp;lt; values; i++) {&lt;BR /&gt;    split (a[i], b, ";");&lt;BR /&gt;    line = line b[1] ",";&lt;BR /&gt;    }&lt;BR /&gt;split (a[values], last_one, ";");&lt;BR /&gt;print line last_one[1];&lt;BR /&gt;} &lt;BR /&gt;----------------&lt;BR /&gt;&lt;BR /&gt;use as : # awk -f test.awk test.txt&lt;BR /&gt;&lt;BR /&gt;The program splits $3 into an array 'a'&lt;BR /&gt;&lt;BR /&gt;It starts by building the first part of the line using $1, $2 and the returned count for the split.&lt;BR /&gt;&lt;BR /&gt;Then it walks all but the last element from 'a' to split again on ";" into array 'b'.&lt;BR /&gt;Element 1 in 'b' has the value.&lt;BR /&gt;Glue that to the line, and add a comma.&lt;BR /&gt;&lt;BR /&gt;Add the last one separately to avoid the extra comma.&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;Hein&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Oct 2010 15:44:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-reformat-flat-file-using-cut-command/m-p/4697183#M659120</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-10-08T15:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to reformat flat file using cut command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-reformat-flat-file-using-cut-command/m-p/4697184#M659121</link>
      <description>ThanQ Hein,&lt;BR /&gt;&lt;BR /&gt;It is very useful. Once again Thanks for  your solution.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Gopi</description>
      <pubDate>Mon, 11 Oct 2010 11:06:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-reformat-flat-file-using-cut-command/m-p/4697184#M659121</guid>
      <dc:creator>Gopi Kishore m</dc:creator>
      <dc:date>2010-10-11T11:06:33Z</dc:date>
    </item>
  </channel>
</rss>

