<?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: Minor shell script question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032922#M756540</link>
    <description>Hi Achilles,&lt;BR /&gt;&lt;BR /&gt;I think you have to be a little creative to achieve that. This example just deletes all numbers in $1 and if anything still remains, $1 was not an integer:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;REST=$(echo "$1"|tr -d [0-9])&lt;BR /&gt;if [ "$REST" = "" ]; then&lt;BR /&gt;echo "it is an intger"&lt;BR /&gt;else&lt;BR /&gt;echo "it is a string"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
    <pubDate>Fri, 09 Mar 2007 03:01:47 GMT</pubDate>
    <dc:creator>john korterman</dc:creator>
    <dc:date>2007-03-09T03:01:47Z</dc:date>
    <item>
      <title>Minor shell script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032921#M756538</link>
      <description>Hello there,&lt;BR /&gt;&lt;BR /&gt;I don't know how to write the statement in order to distinguish the input is integer. it seems as below&lt;BR /&gt;&lt;BR /&gt;if [ $1 is an integer ]; then&lt;BR /&gt;   echo "it is an intger"&lt;BR /&gt;else&lt;BR /&gt;   echo "it is a string"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Fri, 09 Mar 2007 02:24:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032921#M756538</guid>
      <dc:creator>Achilles_2</dc:creator>
      <dc:date>2007-03-09T02:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Minor shell script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032922#M756540</link>
      <description>Hi Achilles,&lt;BR /&gt;&lt;BR /&gt;I think you have to be a little creative to achieve that. This example just deletes all numbers in $1 and if anything still remains, $1 was not an integer:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;REST=$(echo "$1"|tr -d [0-9])&lt;BR /&gt;if [ "$REST" = "" ]; then&lt;BR /&gt;echo "it is an intger"&lt;BR /&gt;else&lt;BR /&gt;echo "it is a string"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Fri, 09 Mar 2007 03:01:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032922#M756540</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2007-03-09T03:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Minor shell script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032923#M756542</link>
      <description>Achilles,&lt;BR /&gt;please see earlier thread:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=945981" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=945981&lt;/A&gt;</description>
      <pubDate>Fri, 09 Mar 2007 03:22:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032923#M756542</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-09T03:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Minor shell script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032924#M756544</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;This handles the determination of unsigned integers:&lt;BR /&gt;&lt;BR /&gt;# N=123&lt;BR /&gt;# [ `expr "${N}" : '[0-9]*'` -eq `expr "${N}" : '.*'` ] &amp;amp;&amp;amp; echo "Integer" || echo "non-integer"&lt;BR /&gt;&lt;BR /&gt;If the value of 'N' consists only of the digits 0-9 for its whole length, then 'N' is an integer.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 09 Mar 2007 08:01:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032924#M756544</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-03-09T08:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Minor shell script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032925#M756546</link>
      <description>Here's one approach:&lt;BR /&gt;&lt;BR /&gt;sub is_signed_int&lt;BR /&gt;{&lt;BR /&gt;  typeset -i GSTAT=255&lt;BR /&gt;  if [[ ${#} -eq 1 ]]&lt;BR /&gt;    then&lt;BR /&gt;      echo "${1}" | grep -E -q '^[+-]{0,1}[0-9]+$'&lt;BR /&gt;      GSTAT=${?}&lt;BR /&gt;    else&lt;BR /&gt;      echo "Function is_signed_int expects exactly 1 arg" &amp;gt;&amp;amp;2&lt;BR /&gt;    fi&lt;BR /&gt;  return ${GSTAT}&lt;BR /&gt;} # is_signed_int&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sub is_int&lt;BR /&gt;{&lt;BR /&gt;  typeset -i GSTAT=255&lt;BR /&gt;  if [[ ${#} -eq 1 ]]&lt;BR /&gt;    then&lt;BR /&gt;      echo "${1}" | grep -E -q '^[0-9]+$'&lt;BR /&gt;      GSTAT=${?}&lt;BR /&gt;    else&lt;BR /&gt;      echo "Function is_int expects exactly 1 arg" &amp;gt;&amp;amp;2&lt;BR /&gt;    fi&lt;BR /&gt;  return ${GSTAT}&lt;BR /&gt;} # is_int&lt;BR /&gt;&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;&lt;BR /&gt;while [[ ${#} -ge 1 ]]&lt;BR /&gt;   do&lt;BR /&gt;      echo "Value ${1} \c"&lt;BR /&gt;      is_signed_int "${1}"&lt;BR /&gt;      STAT=${?}&lt;BR /&gt;      if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;        then&lt;BR /&gt;          echo "is a signed int \c"&lt;BR /&gt;        fi&lt;BR /&gt;      is_int "${1}"&lt;BR /&gt;      if [[ ${STAT} -eq 0 ]]&lt;BR /&gt;        then&lt;BR /&gt;          echo "is an int\c"&lt;BR /&gt;        fi&lt;BR /&gt;      echo&lt;BR /&gt;      shift&lt;BR /&gt;    done&lt;BR /&gt;&lt;BR /&gt;     &lt;BR /&gt;The -q option of egrep returns an exit code of 0 if the pattern matches the regular expression and non-zero otherwise.&lt;BR /&gt;</description>
      <pubDate>Fri, 09 Mar 2007 10:26:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032925#M756546</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-03-09T10:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Minor shell script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032926#M756547</link>
      <description>Thanks you for ALL help. I have achieved what I need.</description>
      <pubDate>Sun, 11 Mar 2007 21:10:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032926#M756547</guid>
      <dc:creator>Achilles_2</dc:creator>
      <dc:date>2007-03-11T21:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: Minor shell script question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032927#M756548</link>
      <description>I closed this subject now</description>
      <pubDate>Sun, 11 Mar 2007 21:10:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/minor-shell-script-question/m-p/5032927#M756548</guid>
      <dc:creator>Achilles_2</dc:creator>
      <dc:date>2007-03-11T21:10:47Z</dc:date>
    </item>
  </channel>
</rss>

