<?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: If statement in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859592#M396142</link>
    <description>do a &lt;BR /&gt;&lt;BR /&gt;$man 1  sh-posix&lt;BR /&gt;&lt;BR /&gt;search for 'Conditional Expressions'&lt;BR /&gt;&lt;BR /&gt;you will find them there</description>
    <pubDate>Sun, 05 Sep 2004 09:18:08 GMT</pubDate>
    <dc:creator>T G Manikandan</dc:creator>
    <dc:date>2004-09-05T09:18:08Z</dc:date>
    <item>
      <title>If statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859590#M396140</link>
      <description>Where can find a manual for if statement?.&lt;BR /&gt;for example .&lt;BR /&gt;&lt;BR /&gt;if [-s ...]&lt;BR /&gt;&lt;BR /&gt;a manual for the option after if (-s ,-f ,-d).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;THANKS&lt;BR /&gt;Rgds.</description>
      <pubDate>Sun, 05 Sep 2004 09:06:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859590#M396140</guid>
      <dc:creator>presage112</dc:creator>
      <dc:date>2004-09-05T09:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: If statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859591#M396141</link>
      <description>See the Brian Brown online "Learning Unix" courses :&lt;BR /&gt;&lt;A href="http://goforit.unk.edu/unix/ostart.htm" target="_blank"&gt;http://goforit.unk.edu/unix/ostart.htm&lt;/A&gt;&lt;BR /&gt;Module 3 : shell scripts, and you will see on the "Shell conditionnal tests" :&lt;BR /&gt;Test  Meaning:&lt;BR /&gt;!=  not equal &lt;BR /&gt;=  equal &lt;BR /&gt;-eq  equal &lt;BR /&gt;-gt  greater than &lt;BR /&gt;-ge greater than or equal &lt;BR /&gt;-lt less than &lt;BR /&gt;-le  less than or equal &lt;BR /&gt;! logic negation &lt;BR /&gt;-a  logical and &lt;BR /&gt;-o  logical or &lt;BR /&gt;-r file true if the file exists and is readable &lt;BR /&gt;-w file  true if the file exists and is writable &lt;BR /&gt;-x file  true if the file exists and is executable &lt;BR /&gt;-s file  true if the file exists and its size &amp;gt; 0 &lt;BR /&gt;-d file  true if the file is a directory &lt;BR /&gt;-f file  true if the file is an ordinary file &lt;BR /&gt;-t filed true if the file descriptor is associated with a terminal &lt;BR /&gt;-n str  true if the length of str is &amp;gt; 0 &lt;BR /&gt;-z str  true if the length of str is zero &lt;BR /&gt;&lt;BR /&gt;Olivier.</description>
      <pubDate>Sun, 05 Sep 2004 09:14:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859591#M396141</guid>
      <dc:creator>Olivier Decorse</dc:creator>
      <dc:date>2004-09-05T09:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: If statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859592#M396142</link>
      <description>do a &lt;BR /&gt;&lt;BR /&gt;$man 1  sh-posix&lt;BR /&gt;&lt;BR /&gt;search for 'Conditional Expressions'&lt;BR /&gt;&lt;BR /&gt;you will find them there</description>
      <pubDate>Sun, 05 Sep 2004 09:18:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859592#M396142</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2004-09-05T09:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: If statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859593#M396143</link>
      <description>A very good doc for any advanced Shell enhancement (I/O Redirection, Performing Arithmetic, Translating Characters, Command Exit Status, etc) :&lt;BR /&gt;&lt;A href="http://users.sdsc.edu/~steube/Bshell/" target="_blank"&gt;http://users.sdsc.edu/~steube/Bshell/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Olivier.</description>
      <pubDate>Sun, 05 Sep 2004 09:27:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859593#M396143</guid>
      <dc:creator>Olivier Decorse</dc:creator>
      <dc:date>2004-09-05T09:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: If statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859594#M396144</link>
      <description>On top of the suggestions above, you can do:&lt;BR /&gt;# man test&lt;BR /&gt;&lt;BR /&gt;That will give you some examples of the test conditions that you can use with the if/fi statement.&lt;BR /&gt;&lt;BR /&gt;Jim</description>
      <pubDate>Sun, 05 Sep 2004 14:23:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859594#M396144</guid>
      <dc:creator>Jim Mallett</dc:creator>
      <dc:date>2004-09-05T14:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: If statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859595#M396145</link>
      <description>we can use if on shell script as,&lt;BR /&gt;&lt;BR /&gt;if [[ &lt;EXPRESSION&gt; ]]&lt;BR /&gt;then&lt;BR /&gt;  &amp;lt; operation's &amp;gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;if [ &lt;EXPRESSION&gt; ]&lt;BR /&gt;then&lt;BR /&gt;  &amp;lt; operation's &amp;gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;where we have need a format as,&lt;BR /&gt;if&lt;SPACE&gt;[&lt;SPACE&gt;&lt;EXPRESSION&gt;&lt;SPACE&gt;]&lt;BR /&gt;then&lt;BR /&gt;  &amp;lt; operation's &amp;gt;&lt;BR /&gt;fi&lt;BR /&gt;  &lt;BR /&gt;if&lt;SPACE&gt;[[&lt;SPACE&gt;&lt;EXPRESSION&gt;&lt;SPACE&gt;]] &lt;BR /&gt;then&lt;BR /&gt;  &lt;OPERATION&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;we have to use if / elif / else as,&lt;BR /&gt;if [[ &lt;EXPRESSION&gt; ]]&lt;BR /&gt;then&lt;BR /&gt;  action1&lt;BR /&gt;elif [[ &lt;EXPRESSION&gt; ]]&lt;BR /&gt;then&lt;BR /&gt;  action2&lt;BR /&gt;elif [[ &lt;EXPRESSION&gt; ]]&lt;BR /&gt;then&lt;BR /&gt;  action3&lt;BR /&gt;else&lt;BR /&gt;  action4&lt;BR /&gt;fi  &lt;BR /&gt;&lt;BR /&gt;-f file        True if file exists and is a regular file.&lt;BR /&gt;-d file        True if file exists and is a directory.&lt;BR /&gt;-s file        True if file exists and has a size greater than zero.&lt;BR /&gt;&lt;BR /&gt;We can encorporate on script as,&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;# Debugging mode&lt;BR /&gt;set -x &lt;BR /&gt;&lt;BR /&gt;########################&lt;BR /&gt;echo "Enter input"&lt;BR /&gt;read input&lt;BR /&gt;&lt;BR /&gt;if [[ -f $input ]]&lt;BR /&gt;then &lt;BR /&gt;  echo "$input is a regular file"&lt;BR /&gt;elif [[ -d $input ]]&lt;BR /&gt;then&lt;BR /&gt;  echo "$input is a directory"&lt;BR /&gt;elif [[ -s $input ]]&lt;BR /&gt;then&lt;BR /&gt;  echo "$input is a file and exists with size greater than zero `ll $PWD/$input`"&lt;BR /&gt;else&lt;BR /&gt;  echo "$input is not needed to check for -d / -f / -s option"&lt;BR /&gt;  exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;# Normal exit&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;We can use another method simply as,&lt;BR /&gt;&lt;BR /&gt;to check is there a file then,&lt;BR /&gt;&lt;BR /&gt;[[ -f &lt;FILENAMEWITH full="" path=""&gt; ]] &amp;amp;&amp;amp; operation.&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;&lt;BR /&gt;[[ -f /stand/vmunix ]] &amp;amp;&amp;amp; echo "System file is there"&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;-Muthu&lt;/FILENAMEWITH&gt;&lt;/EXPRESSION&gt;&lt;/EXPRESSION&gt;&lt;/EXPRESSION&gt;&lt;/OPERATION&gt;&lt;/SPACE&gt;&lt;/EXPRESSION&gt;&lt;/SPACE&gt;&lt;/SPACE&gt;&lt;/SPACE&gt;&lt;/EXPRESSION&gt;&lt;/SPACE&gt;&lt;/SPACE&gt;&lt;/EXPRESSION&gt;&lt;/EXPRESSION&gt;</description>
      <pubDate>Sun, 05 Sep 2004 23:03:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859595#M396145</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-09-05T23:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: If statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859596#M396146</link>
      <description>man page for sh-posix will help u&lt;BR /&gt;regrads&lt;BR /&gt;SK</description>
      <pubDate>Sun, 05 Sep 2004 23:10:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859596#M396146</guid>
      <dc:creator>Sยภเl Kย๓คг</dc:creator>
      <dc:date>2004-09-05T23:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: If statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859597#M396147</link>
      <description>The [] are a shortcut for the 'test' command.&lt;BR /&gt;So indeed 'man test' will give you info.&lt;BR /&gt;But 'test' is also a 'shell built-in', so you may also have a look at the shell's manpage.&lt;BR /&gt;&lt;BR /&gt;JP.</description>
      <pubDate>Mon, 06 Sep 2004 00:50:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859597#M396147</guid>
      <dc:creator>Jeroen Peereboom</dc:creator>
      <dc:date>2004-09-06T00:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: If statement</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859598#M396148</link>
      <description>All comments are helpful ,but I like "man test" more.&lt;BR /&gt;&lt;BR /&gt;Thanks all.</description>
      <pubDate>Mon, 06 Sep 2004 01:16:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/if-statement/m-p/4859598#M396148</guid>
      <dc:creator>presage112</dc:creator>
      <dc:date>2004-09-06T01:16:59Z</dc:date>
    </item>
  </channel>
</rss>

