<?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: Korn Shell String Comparison problem in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108279#M905482</link>
    <description>Does TRU64 have getconf command?&lt;BR /&gt;&lt;BR /&gt;Here's what I get on my hp-ux system.&lt;BR /&gt;&lt;BR /&gt;getconf INT_MAX&lt;BR /&gt;2147483647&lt;BR /&gt;getconf KERNEL_BITS&lt;BR /&gt;64&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
    <pubDate>Mon, 03 Nov 2003 05:17:41 GMT</pubDate>
    <dc:creator>Graham Cameron_1</dc:creator>
    <dc:date>2003-11-03T05:17:41Z</dc:date>
    <item>
      <title>Korn Shell String Comparison problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108272#M905475</link>
      <description>This is the os version:&lt;BR /&gt;&lt;BR /&gt;mddv02@/apps/bin&amp;gt;getconf KERNEL_BITS&lt;BR /&gt;&lt;BR /&gt;64&lt;BR /&gt;&lt;BR /&gt;The following script give the expected result: &lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;this_file_date=12345678901234&lt;BR /&gt;&lt;BR /&gt;last_file_date=02345678901234&lt;BR /&gt;&lt;BR /&gt;if [ $this_file_date -gt $last_file_date ]; then&lt;BR /&gt;&lt;BR /&gt;# echo $raw_file_name &amp;gt;&amp;gt; $FTP_LIST&lt;BR /&gt;&lt;BR /&gt;echo "select:" $this_file_date&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;mddv02@/apps/bin&amp;gt;ksh test2_string.ksh&lt;BR /&gt;&lt;BR /&gt;select: 12345678901234&lt;BR /&gt;&lt;BR /&gt;The Next one doesn't give us the correct result&lt;BR /&gt;&lt;BR /&gt;mddv02@/apps/bin&amp;gt;cat test2_string_no.ksh&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;this_file_date=123456789012345&lt;BR /&gt;&lt;BR /&gt;last_file_date=023456789012345&lt;BR /&gt;&lt;BR /&gt;if [ $this_file_date -gt $last_file_date ]; then&lt;BR /&gt;&lt;BR /&gt;# echo $raw_file_name &amp;gt;&amp;gt; $FTP_LIST&lt;BR /&gt;&lt;BR /&gt;echo "select:" $this_file_date&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;mddv02@/apps/mdsamd/mdsamd/arc/bin&amp;gt;ksh test2_string_no.ksh&lt;BR /&gt;&lt;BR /&gt;mddv02@/apps/mdsamd/mdsamd/arc/bin&amp;gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;So the problem if the value of the string is more than 14 characters it can not compare correctly (the second script is the one with more than 14 characters). Is it a bug? if it's a bug, any fix? Or is this the limitation of the HPUX?&lt;BR /&gt;&lt;BR /&gt;(BTW those 2 scripts can run in Tru64 Unix without problem)&lt;BR /&gt;&lt;BR /&gt;Thank You,&lt;BR /&gt;</description>
      <pubDate>Mon, 03 Nov 2003 02:02:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108272#M905475</guid>
      <dc:creator>irt_1</dc:creator>
      <dc:date>2003-11-03T02:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell String Comparison problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108273#M905476</link>
      <description>These have to fit in a "long integer" which makes these two variables  -2045911175 and&lt;BR /&gt;1972608889 respectively.  My guess is that True64 has a longer long.</description>
      <pubDate>Mon, 03 Nov 2003 02:15:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108273#M905476</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-11-03T02:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell String Comparison problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108274#M905477</link>
      <description>By the way,&lt;BR /&gt; &lt;BR /&gt;You can get around the problem like this&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;this_file_date=123456789012345&lt;BR /&gt;&lt;BR /&gt;last_file_date=023456789012345&lt;BR /&gt;&lt;BR /&gt;(( result = $this_file_date - $last_file_date ))&lt;BR /&gt;&lt;BR /&gt;if [ $result -gt 0 ]; then&lt;BR /&gt;&lt;BR /&gt;# echo $raw_file_name &amp;gt;&amp;gt; $FTP_LIST&lt;BR /&gt;&lt;BR /&gt;echo "select:" $this_file_date&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Mon, 03 Nov 2003 02:30:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108274#M905477</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-11-03T02:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell String Comparison problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108275#M905478</link>
      <description>Hi.&lt;BR /&gt;&lt;BR /&gt;I suggest to use 'bc' command to handle large integers:&lt;BR /&gt;&lt;BR /&gt;echo "if ($this_file_date&amp;gt;$last_file_date) a=a+1; a" | bc | read OUTCOME&lt;BR /&gt;if [[ "$OUTCOME" -eq 1 ]]&lt;BR /&gt;then&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 03 Nov 2003 03:52:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108275#M905478</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2003-11-03T03:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell String Comparison problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108276#M905479</link>
      <description>As suggested you need to take care with long integer arithmetic, the shell doesn't handle too well, bc is better.&lt;BR /&gt;&lt;BR /&gt;One of the suggestions above may not give the results you expect. ie.&lt;BR /&gt;&lt;BR /&gt;# this_file_date=123456789012345&lt;BR /&gt;# last_file_date=023456789012345&lt;BR /&gt;# (( result = $this_file_date - $last_file_date ))&lt;BR /&gt;# echo $result&lt;BR /&gt;276447232&lt;BR /&gt;&lt;BR /&gt;whereas if you use bc:&lt;BR /&gt;# bc&lt;BR /&gt;&lt;BR /&gt;123456789012345-023456789012345&lt;BR /&gt;100000000000000&lt;BR /&gt;&lt;BR /&gt;There have been previous neat solutions where bc is used as a co-process from a shell.&lt;BR /&gt;&lt;BR /&gt;Something like &lt;BR /&gt;&lt;BR /&gt;# bc |&amp;amp;&lt;BR /&gt;# print -p $this_file_date -$last_file_date&lt;BR /&gt;# read -p answer&lt;BR /&gt;# if [ $answer -gt 0 ] ;then etc...;fi&lt;BR /&gt;# print -p quit&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
      <pubDate>Mon, 03 Nov 2003 04:21:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108276#M905479</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-11-03T04:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell String Comparison problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108277#M905480</link>
      <description>Graham, &lt;BR /&gt; &lt;BR /&gt;I realised whilst out having a quick smoke that the workaround I posted earlier is really not a good idea and if it works, it works for the wrong reasons.&lt;BR /&gt; &lt;BR /&gt;I'd do it in perl :)</description>
      <pubDate>Mon, 03 Nov 2003 04:32:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108277#M905480</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-11-03T04:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell String Comparison problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108278#M905481</link>
      <description>Hi Guys, &lt;BR /&gt;&lt;BR /&gt;Thanks alot for the very quick answer. I think the problem is more like what Mark Grant said. is about the diff. between how long the integer value in HPUX and Tru64.&lt;BR /&gt;&lt;BR /&gt;Then another question pop up. Anyone know  how long the integer in HP/UX Korn Shell? Can we use longer integer value? &lt;BR /&gt;&lt;BR /&gt;The problem I can not just change the script, is by the Application Vendor. But if it's the way HPUX integer should be, I can ask the Apps Vendor to change, as long as it is not a bug.&lt;BR /&gt;&lt;BR /&gt;Thank again,&lt;BR /&gt;&lt;BR /&gt;Iwan &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 03 Nov 2003 05:07:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108278#M905481</guid>
      <dc:creator>irt_1</dc:creator>
      <dc:date>2003-11-03T05:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell String Comparison problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108279#M905482</link>
      <description>Does TRU64 have getconf command?&lt;BR /&gt;&lt;BR /&gt;Here's what I get on my hp-ux system.&lt;BR /&gt;&lt;BR /&gt;getconf INT_MAX&lt;BR /&gt;2147483647&lt;BR /&gt;getconf KERNEL_BITS&lt;BR /&gt;64&lt;BR /&gt;&lt;BR /&gt;-- Graham</description>
      <pubDate>Mon, 03 Nov 2003 05:17:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108279#M905482</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-11-03T05:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell String Comparison problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108280#M905483</link>
      <description>Have a look at /usr/include/sys/_inttypes.h for a definitive list.&lt;BR /&gt; &lt;BR /&gt;I suspect you need to start talking to your vendor!</description>
      <pubDate>Mon, 03 Nov 2003 06:29:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108280#M905483</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-11-03T06:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell String Comparison problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108281#M905484</link>
      <description>Looks like your numbers are out of range.&lt;BR /&gt;This is not a HP-UX problem, but a ksh problem.&lt;BR /&gt;Try to compare the strings instead:&lt;BR /&gt;if [[ $string1 &amp;gt; $string2 ]]&lt;BR /&gt;then&lt;BR /&gt;do_something&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Tue, 04 Nov 2003 04:13:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-string-comparison-problem/m-p/3108281#M905484</guid>
      <dc:creator>Armin Kunaschik</dc:creator>
      <dc:date>2003-11-04T04:13:09Z</dc:date>
    </item>
  </channel>
</rss>

