<?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: help shell script if..else fi in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543665#M701833</link>
    <description>in solaris &amp;lt;&amp;gt; is : if $TEST is diferent ""&lt;BR /&gt;&lt;BR /&gt;Thank, I solved my problem:&lt;BR /&gt;...&lt;BR /&gt;if [ x$TEST == "" ] &lt;BR /&gt;then&lt;BR /&gt; echo "$TEST is null"&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;********if is true*************&lt;BR /&gt;ouput , set -x&lt;BR /&gt;TEST=`grep ou file`&lt;BR /&gt;++ TEST=&lt;BR /&gt;++ '[' x == x ']'&lt;BR /&gt;++ echo ' is null'&lt;BR /&gt; is null&lt;BR /&gt;&lt;BR /&gt;*********if is FALSE************&lt;BR /&gt;&lt;BR /&gt;++ TEST=*oufileover.ou&lt;BR /&gt;++ '[' 'x*oufileover.ou' == x ']'&lt;BR /&gt;++ echo 'action'&lt;BR /&gt;action&lt;BR /&gt;</description>
    <pubDate>Fri, 13 May 2005 08:01:53 GMT</pubDate>
    <dc:creator>Jairo Campana</dc:creator>
    <dc:date>2005-05-13T08:01:53Z</dc:date>
    <item>
      <title>help shell script if..else fi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543659#M701827</link>
      <description>hello I have a problem&lt;BR /&gt;when make set -x obtaing a error line 20&lt;BR /&gt; '[' ']'&lt;BR /&gt;./filtra.ori: : No such file or directory&lt;BR /&gt;echo "$TEST is null"&lt;BR /&gt;.....&lt;BR /&gt;.....&lt;BR /&gt;if [ $? -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt; echo "Hello"&lt;BR /&gt; TEST=`grep ou file`&lt;BR /&gt; if [ $TEST &amp;lt;&amp;gt; "" ]      #line 20&lt;BR /&gt;    echo "$TEST is null"&lt;BR /&gt; else&lt;BR /&gt;    echo "action.."&lt;BR /&gt; fi&lt;BR /&gt;else&lt;BR /&gt;  echo "hello bad"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 May 2005 14:17:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543659#M701827</guid>
      <dc:creator>Jairo Campana</dc:creator>
      <dc:date>2005-05-12T14:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: help shell script if..else fi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543660#M701828</link>
      <description>What is:&lt;BR /&gt;&lt;BR /&gt; if [ $TEST &amp;lt;&amp;gt; "" ]&lt;BR /&gt;&lt;BR /&gt;supposed to do?  That is not a valid comparison.  Do want the 'then' action to when TEST is null or when TEST is NOT NULL?&lt;BR /&gt;&lt;BR /&gt;You are also missing a 'then' after that if statement.</description>
      <pubDate>Thu, 12 May 2005 14:22:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543660#M701828</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2005-05-12T14:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: help shell script if..else fi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543661#M701829</link>
      <description>if [ $TEST != "" ]&lt;BR /&gt;then&lt;BR /&gt;  &lt;DO some="" action="https://community.hpe.com/"&gt;&lt;BR /&gt;else&lt;BR /&gt;  &lt;DO some="" other="" action="https://community.hpe.com/"&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;BTW, what is the &amp;lt;&amp;gt; you have? Is this "not equal"? I am familar with the '!=' and the '-ne'. Haven't seen the '&amp;lt;&amp;gt;' but this could be lack of exposure on my part...&lt;/DO&gt;&lt;/DO&gt;</description>
      <pubDate>Thu, 12 May 2005 14:34:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543661#M701829</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2005-05-12T14:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: help shell script if..else fi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543662#M701830</link>
      <description>Suspect that you need != instead of &amp;lt;&amp;gt; since its specifically complaining about the TEST line .   See 'man sh' for what you can use here.&lt;BR /&gt;&lt;BR /&gt;Also make sure that the you have spaces next to the [ and ] .&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 May 2005 14:46:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543662#M701830</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2005-05-12T14:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: help shell script if..else fi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543663#M701831</link>
      <description>As you are using [ ] evaluation, you can also try using the '-z' switch.&lt;BR /&gt;&lt;BR /&gt;if [ ! -z "$TEST" ]&lt;BR /&gt;then&lt;BR /&gt;&lt;BR /&gt;See 'man test' for different options to single-[]'s, as against the possible shell internal ([[ ]], as in posix and korn shells) evaluation/testing.</description>
      <pubDate>Thu, 12 May 2005 18:50:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543663#M701831</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2005-05-12T18:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: help shell script if..else fi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543664#M701832</link>
      <description>You need to flag variables that contain strings by using double quotes. The reason is that if $TEST is null, the shell replaces $TEST with nothing and your test becomes:&lt;BR /&gt; &lt;BR /&gt;if [ &amp;lt;&amp;gt; "" ]&lt;BR /&gt; &lt;BR /&gt;which makes no sense. Enclose $TEST with quotes and the statement will look like this:&lt;BR /&gt; &lt;BR /&gt;if [ "" &amp;lt;&amp;gt; "" ]&lt;BR /&gt; &lt;BR /&gt;But as mentioned, &amp;lt;&amp;gt; is not a valid shell expression. The 3 comparison operators are = &amp;lt; . so to get "not equal", use the ! as negation. So not-equal is: != and your test should be:&lt;BR /&gt; &lt;BR /&gt;if [ "$TEST" != "" ]&lt;BR /&gt;or&lt;BR /&gt;if [ -z "$TEST" ]</description>
      <pubDate>Thu, 12 May 2005 22:38:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543664#M701832</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-05-12T22:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: help shell script if..else fi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543665#M701833</link>
      <description>in solaris &amp;lt;&amp;gt; is : if $TEST is diferent ""&lt;BR /&gt;&lt;BR /&gt;Thank, I solved my problem:&lt;BR /&gt;...&lt;BR /&gt;if [ x$TEST == "" ] &lt;BR /&gt;then&lt;BR /&gt; echo "$TEST is null"&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;********if is true*************&lt;BR /&gt;ouput , set -x&lt;BR /&gt;TEST=`grep ou file`&lt;BR /&gt;++ TEST=&lt;BR /&gt;++ '[' x == x ']'&lt;BR /&gt;++ echo ' is null'&lt;BR /&gt; is null&lt;BR /&gt;&lt;BR /&gt;*********if is FALSE************&lt;BR /&gt;&lt;BR /&gt;++ TEST=*oufileover.ou&lt;BR /&gt;++ '[' 'x*oufileover.ou' == x ']'&lt;BR /&gt;++ echo 'action'&lt;BR /&gt;action&lt;BR /&gt;</description>
      <pubDate>Fri, 13 May 2005 08:01:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-shell-script-if-else-fi/m-p/3543665#M701833</guid>
      <dc:creator>Jairo Campana</dc:creator>
      <dc:date>2005-05-13T08:01:53Z</dc:date>
    </item>
  </channel>
</rss>

