<?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: Data formating in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/data-formating/m-p/3193507#M792028</link>
    <description>Thank you Curt, both solutions are a winner. My personal preference is for awk but as the great master said: "There is more than one way to skin a cat"&lt;BR /&gt;Thanks again.&lt;BR /&gt;Victor&lt;BR /&gt;</description>
    <pubDate>Wed, 18 Feb 2004 09:48:41 GMT</pubDate>
    <dc:creator>Victor Pavon</dc:creator>
    <dc:date>2004-02-18T09:48:41Z</dc:date>
    <item>
      <title>Data formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/data-formating/m-p/3193504#M792025</link>
      <description>Hello:&lt;BR /&gt;&lt;BR /&gt;I was put to the task of formating data blocks from our legacy system to a flat ascii format. I have created a simple script that worked great until the programmers started sending huge data records beyond the old system maximun of 756 characters. We have agreed to insert an undescore (_) on position 756 indicating that the next line were to be continuation of the same record. So, I came to the idea of searching data until it finds an undescore and a line feed (_\012) and delete the pair, hence concatenating the next line. This was not as simple as I had planned. See model script bellow:&lt;BR /&gt;...&lt;BR /&gt;# Split data stream into 756 chunks and delete trailing spaces&lt;BR /&gt;fold -b -w756 $1 | sed 's/;[ ]*/;/g' &amp;gt; $1.foo&lt;BR /&gt;# replace '_' with 'u' and '\012' with 'l'&lt;BR /&gt;sed 's/_/u/g' $1.foo | tr '\012' 'l' &amp;gt; $1.mid&lt;BR /&gt;# add an end of record for sed to see bottom of file&lt;BR /&gt;echo '' &amp;gt;&amp;gt; $1.mid&lt;BR /&gt;# Delete 'ul' (concactenate), add linefeed and replace the _ were they should be&lt;BR /&gt;sed 's/ul//g' $1.mid | tr 'l' '\012' | tr 'u' '_' &amp;gt; $1.dat&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;The problem with this is that Iam IOing like a madd man. The script is building 3 times as many files to make one usable output file. Also, input data may have l's and u's in it, causing unexpected results.&lt;BR /&gt;This is a question for all of you sed, awk and perl masters.&lt;BR /&gt;Is there a way get a flat ASCII file using the least middle steps? May be a oneliner (or two)?&lt;BR /&gt;&lt;BR /&gt;Appreciate any ideas. Included is a tiny sample input file.</description>
      <pubDate>Mon, 16 Feb 2004 18:45:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/data-formating/m-p/3193504#M792025</guid>
      <dc:creator>Victor Pavon</dc:creator>
      <dc:date>2004-02-16T18:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Data formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/data-formating/m-p/3193505#M792026</link>
      <description>maybe this will work for you&lt;BR /&gt;&lt;BR /&gt;fold -b -w756 $1 |&lt;BR /&gt;while read line&lt;BR /&gt;do&lt;BR /&gt;#everything but last char&lt;BR /&gt;x=${line%?}&lt;BR /&gt;lastChar=${line#$x}&lt;BR /&gt;if [[ $lastChar = "_" ]] ;then&lt;BR /&gt;#print line without the ending underscore&lt;BR /&gt;#and without a newline&lt;BR /&gt;print -nr $x&lt;BR /&gt;else&lt;BR /&gt;print -r $line&lt;BR /&gt;done &amp;gt; $1.dat</description>
      <pubDate>Mon, 16 Feb 2004 19:41:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/data-formating/m-p/3193505#M792026</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-02-16T19:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Data formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/data-formating/m-p/3193506#M792027</link>
      <description>same thing using awk&lt;BR /&gt;&lt;BR /&gt;fold -b -w756 $1 |&lt;BR /&gt;awk '{&lt;BR /&gt;x=length($0);&lt;BR /&gt;lastChar=substr($0,x,1);&lt;BR /&gt;b=substr($0,1,x-1);&lt;BR /&gt;if ( lastChar == "_" )&lt;BR /&gt;printf("%s",b);&lt;BR /&gt;else&lt;BR /&gt;printf("%s\n",$0);&lt;BR /&gt;}'</description>
      <pubDate>Mon, 16 Feb 2004 19:54:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/data-formating/m-p/3193506#M792027</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-02-16T19:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Data formating</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/data-formating/m-p/3193507#M792028</link>
      <description>Thank you Curt, both solutions are a winner. My personal preference is for awk but as the great master said: "There is more than one way to skin a cat"&lt;BR /&gt;Thanks again.&lt;BR /&gt;Victor&lt;BR /&gt;</description>
      <pubDate>Wed, 18 Feb 2004 09:48:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/data-formating/m-p/3193507#M792028</guid>
      <dc:creator>Victor Pavon</dc:creator>
      <dc:date>2004-02-18T09:48:41Z</dc:date>
    </item>
  </channel>
</rss>

