<?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: need help in simple scripts in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-in-simple-scripts/m-p/3090246#M144652</link>
    <description>the only thing i can see that might be a problem is the use of [...] which is obsolete.  it has been replaced by [[...]] and ((...)).&lt;BR /&gt;&lt;BR /&gt;try using &lt;BR /&gt;if (( "$col_4th &amp;gt; "$max_cpu" ))&lt;BR /&gt;then&lt;BR /&gt;....&lt;BR /&gt;&lt;BR /&gt;but you could do this all within awk&lt;BR /&gt;&lt;BR /&gt;sort -r -k 4,4 xfrdGLOBAL.asc | tr -d " " |&lt;BR /&gt;awk -F"|" '{&lt;BR /&gt;if ( $4 &amp;gt; max ) max = $4;&lt;BR /&gt;} END { print max;}'&lt;BR /&gt;</description>
    <pubDate>Fri, 10 Oct 2003 00:03:59 GMT</pubDate>
    <dc:creator>curt larson_1</dc:creator>
    <dc:date>2003-10-10T00:03:59Z</dc:date>
    <item>
      <title>need help in simple scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-in-simple-scripts/m-p/3090244#M144650</link>
      <description>I am trying to write a ksh script to do data comparison for a flat file. But the data is in decimal e.g. 56.48, 45.68, 56.22, etc.&lt;BR /&gt;&lt;BR /&gt;I tried doing the following but it outputs only the last max value = 55.87. Can some tell me how to do decimal comparison using ksh scripts?&lt;BR /&gt;&lt;BR /&gt;sort -r -k 4,4 xfrdGLOBAL.asc &amp;gt; xfrdGLOBAL.sort&lt;BR /&gt;&lt;BR /&gt;cat xfrdGLOBAL.sort | sed -e '1,$s/ //g' &amp;gt; xfrdGLOBAL.nospace&lt;BR /&gt;max_cpu=0&lt;BR /&gt;&lt;BR /&gt;        for REC in `cat xfrdGLOBAL.nospace`&lt;BR /&gt;            do&lt;BR /&gt;                col_4th=`echo $REC | awk -F'|' '{print $4}'`&lt;BR /&gt;&lt;BR /&gt;                if [ $col_4th -gt $max_cpu ]&lt;BR /&gt;                then&lt;BR /&gt;                        max_cpu=$col_4th&lt;BR /&gt;                fi&lt;BR /&gt;        done&lt;BR /&gt;echo ""&lt;BR /&gt;echo $max_cpu&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;My data file is as follows&lt;BR /&gt;09/22/03|00:00|   300| 55.12|&lt;BR /&gt;09/22/03|00:05|   299| 54.93|&lt;BR /&gt;09/22/03|00:10|   299| 54.91|&lt;BR /&gt;09/22/03|00:15|   300| 54.93|&lt;BR /&gt;09/22/03|00:20|   299| 54.88|&lt;BR /&gt;09/22/03|00:25|   299| 54.88|&lt;BR /&gt;09/22/03|00:30|   299| 55.00|&lt;BR /&gt;09/22/03|00:35|   299| 54.91|&lt;BR /&gt;09/22/03|00:40|   300| 55.95|&lt;BR /&gt;09/22/03|00:45|   299| 54.94|&lt;BR /&gt;09/22/03|00:50|   299| 55.87|&lt;BR /&gt;09/22/03|00:55|   299| 54.88|&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Oct 2003 23:21:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-in-simple-scripts/m-p/3090244#M144650</guid>
      <dc:creator>YLTan</dc:creator>
      <dc:date>2003-10-09T23:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: need help in simple scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-in-simple-scripts/m-p/3090245#M144651</link>
      <description>Could you explain what you mean by data comparison.  As far as I can see, your script appears to try and find the highest value out of a list.  It does that successsfully so what are you trying to compare?</description>
      <pubDate>Thu, 09 Oct 2003 23:49:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-in-simple-scripts/m-p/3090245#M144651</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-10-09T23:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: need help in simple scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-in-simple-scripts/m-p/3090246#M144652</link>
      <description>the only thing i can see that might be a problem is the use of [...] which is obsolete.  it has been replaced by [[...]] and ((...)).&lt;BR /&gt;&lt;BR /&gt;try using &lt;BR /&gt;if (( "$col_4th &amp;gt; "$max_cpu" ))&lt;BR /&gt;then&lt;BR /&gt;....&lt;BR /&gt;&lt;BR /&gt;but you could do this all within awk&lt;BR /&gt;&lt;BR /&gt;sort -r -k 4,4 xfrdGLOBAL.asc | tr -d " " |&lt;BR /&gt;awk -F"|" '{&lt;BR /&gt;if ( $4 &amp;gt; max ) max = $4;&lt;BR /&gt;} END { print max;}'&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Oct 2003 00:03:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-in-simple-scripts/m-p/3090246#M144652</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-10-10T00:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: need help in simple scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-in-simple-scripts/m-p/3090247#M144653</link>
      <description>your sort should probably be:&lt;BR /&gt;sort -r -t"|" -k 4n,4&lt;BR /&gt;&lt;BR /&gt;use "|" as the delimiter between keys&lt;BR /&gt;and 4n,4  sort by arithmetic value&lt;BR /&gt;&lt;BR /&gt;and by sorting you probably don't need to do the comparision at all&lt;BR /&gt;&lt;BR /&gt;sort -r -t"|" -k 4n,4 xfrdGLOBAL.asc |&lt;BR /&gt;awk -F"|" '{print $4;exit}'&lt;BR /&gt;&lt;BR /&gt;or don't use sort at all&lt;BR /&gt;&lt;BR /&gt;cat xfrdGLOBAL.asc |&lt;BR /&gt;awk -F"|" '{&lt;BR /&gt;if ( $4 &amp;gt; max ) max = $4;&lt;BR /&gt;} END {print $4;}'</description>
      <pubDate>Fri, 10 Oct 2003 00:21:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-in-simple-scripts/m-p/3090247#M144653</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-10-10T00:21:36Z</dc:date>
    </item>
  </channel>
</rss>

