<?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: checking if a variable is an integer or  a string in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933876#M102417</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;There are a lot of examples inside the ITRC, check below link.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=66578" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=66578&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;search I used in google "site:forums1.itrc.hp.com integer string"&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Robert-Jan</description>
    <pubDate>Sun, 16 Oct 2005 14:22:46 GMT</pubDate>
    <dc:creator>Robert-Jan Goossens_1</dc:creator>
    <dc:date>2005-10-16T14:22:46Z</dc:date>
    <item>
      <title>checking if a variable is an integer or  a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933874#M102415</link>
      <description>hello,&lt;BR /&gt;does anyone know how can I check whether a varible value contains an integer or a string?&lt;BR /&gt;on simple bourne shell script&lt;BR /&gt;Itai</description>
      <pubDate>Sun, 16 Oct 2005 14:08:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933874#M102415</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2005-10-16T14:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: checking if a variable is an integer or  a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933875#M102416</link>
      <description>We will leverage enhanced grep (-E) and use an anchored (at both ends) pattern; use the -q option because we only care about the status of the matched string :&lt;BR /&gt;&lt;BR /&gt;echo "${MYVAR}" | grep -E -q -e '^-{0,1}[0-9]+$'&lt;BR /&gt;GSTAT=${?}&lt;BR /&gt;if [ ${GSTAT} -eq 0 ]&lt;BR /&gt;  then&lt;BR /&gt;    echo "${MYVAR} is an integer"&lt;BR /&gt;  else &lt;BR /&gt;    echo "${MYVAR} ain't an integer"&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;You can drop the -{0,1} if only positive values pass the test.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 16 Oct 2005 14:19:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933875#M102416</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-10-16T14:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: checking if a variable is an integer or  a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933876#M102417</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;There are a lot of examples inside the ITRC, check below link.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=66578" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=66578&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;search I used in google "site:forums1.itrc.hp.com integer string"&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Robert-Jan</description>
      <pubDate>Sun, 16 Oct 2005 14:22:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933876#M102417</guid>
      <dc:creator>Robert-Jan Goossens_1</dc:creator>
      <dc:date>2005-10-16T14:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: checking if a variable is an integer or  a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933877#M102418</link>
      <description>In Unix, if you don't find at least 5 different ways to do the same thing, you aren't looking hard enough. Here's an interesting method: Use tr to remove digits and see if anything is left:&lt;BR /&gt; &lt;BR /&gt;if [ "$(echo $MYVAR | tr -d '[:digit:]')" = "" ]&lt;BR /&gt;then&lt;BR /&gt; echo "All digits"&lt;BR /&gt;else&lt;BR /&gt; echo "$MYVAR has non-digits"&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Sun, 16 Oct 2005 21:02:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933877#M102418</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-10-16T21:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: checking if a variable is an integer or  a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933878#M102419</link>
      <description>As Bill says ...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Say your variable is called $VAR.&lt;BR /&gt;&lt;BR /&gt;typeset -i INT="$VAR" 2&amp;gt; /dev/null&lt;BR /&gt;if [ "$?" -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo "Is an integer"&lt;BR /&gt;else&lt;BR /&gt;echo "Is not an integer"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 17 Oct 2005 05:05:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933878#M102419</guid>
      <dc:creator>Stephen Keane</dc:creator>
      <dc:date>2005-10-17T05:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: checking if a variable is an integer or  a string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933879#M102420</link>
      <description>thanks everyone,&lt;BR /&gt;you really helped my a lot</description>
      <pubDate>Mon, 17 Oct 2005 07:27:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/checking-if-a-variable-is-an-integer-or-a-string/m-p/4933879#M102420</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2005-10-17T07:27:57Z</dc:date>
    </item>
  </channel>
</rss>

