<?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: Question about variables in script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943800#M930571</link>
    <description>export VAR=`expr ${VAR:-0} + 1`&lt;BR /&gt;&lt;BR /&gt;your logic is rather strange. If *not* defined increment, else set to 0&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
    <pubDate>Fri, 04 Apr 2003 08:42:44 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2003-04-04T08:42:44Z</dc:date>
    <item>
      <title>Question about variables in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943799#M930570</link>
      <description>Hello.&lt;BR /&gt;1. How can i check if variable exist or not in sh ? (I know how to do it in csh) E.G.&lt;BR /&gt;if [ $VAR not exist ]; then&lt;BR /&gt;     VAR=$(expr $VAR + 1)&lt;BR /&gt;     export VAR&lt;BR /&gt;else &lt;BR /&gt;     VAR=0&lt;BR /&gt;     export VAR&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;2. What is the best syntax for arithmetic operations like VAR=$(expr $VAR + 1) in sh? I don't want to use expr command, i'd like something like VAR++ in C language.</description>
      <pubDate>Fri, 04 Apr 2003 08:26:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943799#M930570</guid>
      <dc:creator>Artyom Voronchihin</dc:creator>
      <dc:date>2003-04-04T08:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Question about variables in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943800#M930571</link>
      <description>export VAR=`expr ${VAR:-0} + 1`&lt;BR /&gt;&lt;BR /&gt;your logic is rather strange. If *not* defined increment, else set to 0&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn</description>
      <pubDate>Fri, 04 Apr 2003 08:42:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943800#M930571</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-04-04T08:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Question about variables in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943801#M930572</link>
      <description>1. To check if a variable exists;&lt;BR /&gt;&lt;BR /&gt;[ -n "${&lt;VARIABLE&gt;:-}" ] &amp;amp;&amp;amp; echo exists&lt;BR /&gt;&lt;BR /&gt;replace &lt;VARIABLE&gt; for the variable name to check.&lt;BR /&gt;&lt;BR /&gt;2. let &lt;VARIABLE&gt;=$&lt;VARIABLE&gt;+1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/VARIABLE&gt;&lt;/VARIABLE&gt;&lt;/VARIABLE&gt;&lt;/VARIABLE&gt;</description>
      <pubDate>Fri, 04 Apr 2003 08:45:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943801#M930572</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2003-04-04T08:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Question about variables in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943802#M930573</link>
      <description>Ooooops ! Mixed up sections. Correct would be&lt;BR /&gt;if [ $VAR not exist ]; then &lt;BR /&gt;     VAR=0 &lt;BR /&gt;     export VAR &lt;BR /&gt;else &lt;BR /&gt;    VAR=$(expr $VAR + 1)&lt;BR /&gt;    export VAR &lt;BR /&gt;fi</description>
      <pubDate>Fri, 04 Apr 2003 08:49:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943802#M930573</guid>
      <dc:creator>Artyom Voronchihin</dc:creator>
      <dc:date>2003-04-04T08:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Question about variables in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943803#M930574</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Use the -z option as shown in man test&lt;BR /&gt;for an existing variable.&lt;BR /&gt;&lt;BR /&gt;if [ -z "$var" ]&lt;BR /&gt;then&lt;BR /&gt;echo not set&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;See typeset -i in sh man&lt;BR /&gt;&lt;BR /&gt;typeset -i x=1&lt;BR /&gt;x=$x+1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;             Steve Steel</description>
      <pubDate>Fri, 04 Apr 2003 08:49:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943803#M930574</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2003-04-04T08:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Question about variables in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943804#M930575</link>
      <description>1)&lt;BR /&gt;&lt;BR /&gt;if [[ -n ${VAR:-} ]]; then&lt;BR /&gt;  ((VAR+=1))&lt;BR /&gt;else&lt;BR /&gt;  VAR=0&lt;BR /&gt;fi&lt;BR /&gt;export VAR&lt;BR /&gt;&lt;BR /&gt;2)&lt;BR /&gt;&lt;BR /&gt;((VAR+=1)) -or-&lt;BR /&gt;((VAR=VAR+1)) -or-&lt;BR /&gt;VAR=$((VAR+1))&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Best regards...&lt;BR /&gt; Dietmar.</description>
      <pubDate>Fri, 04 Apr 2003 08:51:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-about-variables-in-script/m-p/2943804#M930575</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2003-04-04T08:51:02Z</dc:date>
    </item>
  </channel>
</rss>

