<?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: Conditional Expressions doubt in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239857#M714609</link>
    <description>There is no difference as your output also proves.&lt;BR /&gt;&lt;BR /&gt;sks</description>
    <pubDate>Mon, 05 Apr 2004 09:59:42 GMT</pubDate>
    <dc:creator>Sanjay Kumar Suri</dc:creator>
    <dc:date>2004-04-05T09:59:42Z</dc:date>
    <item>
      <title>Conditional Expressions doubt</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239851#M714603</link>
      <description>I would like to know what is the difference (if any) between using "-h" and "-L" to know if a file is a symbolic link. And also the difference between using "-a" and "-e" to know if a file exists. On line help doen't say if there is or if there is not a difference, so I like to be sure.</description>
      <pubDate>Mon, 05 Apr 2004 09:22:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239851#M714603</guid>
      <dc:creator>Ester Saez</dc:creator>
      <dc:date>2004-04-05T09:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Expressions doubt</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239852#M714604</link>
      <description>Ester,&lt;BR /&gt;&lt;BR /&gt;what's the context?&lt;BR /&gt;&lt;BR /&gt;If I look at 'test' manpage, I cannot find -L, -e and -a.&lt;BR /&gt;&lt;BR /&gt;So, what's the language are you 'writing' in?&lt;BR /&gt;&lt;BR /&gt;JP</description>
      <pubDate>Mon, 05 Apr 2004 09:37:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239852#M714604</guid>
      <dc:creator>Jeroen Peereboom</dc:creator>
      <dc:date>2004-04-05T09:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Expressions doubt</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239853#M714605</link>
      <description>I know it's Monday and I might be missing something, but what are you using to test this that you see these flags in the man page? test(1) only shows -h for symbolic links and -a for binary AND operator... no -L or -e at all... file existence is -f.</description>
      <pubDate>Mon, 05 Apr 2004 09:40:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239853#M714605</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2004-04-05T09:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Expressions doubt</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239854#M714606</link>
      <description>You really have to identify the shell that you are using for a complete difference but if I assume that you are using the POSIX shell then there is no difference between -L and -h as both will test if a file is a symbolic link -- but only if using the shell's internal test operator. -L means nothing to the test command. Also, -e is only known to the shell's internal test operator and -a is actually an AND operator to the test command.&lt;BR /&gt;&lt;BR /&gt;The best way to avoid all this confussion is to adopt the "double brackets" approach:&lt;BR /&gt;&lt;BR /&gt;This version will always use the shell's internal test operator (and is thus more efficient):&lt;BR /&gt;if [[ $(a) -gt $(b) &amp;amp;&amp;amp; -f "${MYFILE}" ]]&lt;BR /&gt;then&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;This equivalent version will call the external test command:&lt;BR /&gt;&lt;BR /&gt;if [ $(a) -gt $(b) -a -f "${MYFILE}" ]&lt;BR /&gt;then&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Note that the syntax is a little different in the two cases.&lt;BR /&gt;&lt;BR /&gt;If you must run under the Bourne shell for portability then you should always use the test command and stay within its more limited set of operators but if you know you will always be ruunning on a Korn or POSIX shell or bash then I would favor the internal test operator.&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Apr 2004 09:44:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239854#M714606</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-04-05T09:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Expressions doubt</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239855#M714607</link>
      <description>Oops, the $a's and $b's should have had {}'s around them instead of ()'s:&lt;BR /&gt;&lt;BR /&gt;if [[ ${a} -gt ${b} &amp;amp;&amp;amp; -f "${MYFILE}" ]]&lt;BR /&gt;then&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Apr 2004 09:50:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239855#M714607</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-04-05T09:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Expressions doubt</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239856#M714608</link>
      <description>Sorry for being so cryptic. I am talking abour Shell Script, using sh shell. "man sh-posix" sayig that -h and -L can be used to know if a file is a symbolic link nad that -a and -e can be used to know if a file exists.&lt;BR /&gt;Check this example:&lt;BR /&gt;&lt;BR /&gt;"pru.sh" 17 lines, 183 characters &lt;BR /&gt;file="/tmp/pru/sbinsh"&lt;BR /&gt;if [ -a ${file} ]; then&lt;BR /&gt;  echo "-a"&lt;BR /&gt;fi&lt;BR /&gt;if [ -e ${file} ]; then&lt;BR /&gt;  echo "-e"&lt;BR /&gt;fi&lt;BR /&gt;if [ -h ${file} ]; then&lt;BR /&gt;  echo "-h"&lt;BR /&gt;fi&lt;BR /&gt;if [ -L ${file} ]; then&lt;BR /&gt;  echo "-L"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;# ll&lt;BR /&gt;total 2&lt;BR /&gt;-rwx------   1 root       sistemas       183 Apr  5 16:46 pru.sh&lt;BR /&gt;lrwxrwxrwx   1 root       sistemas         8 Apr  5 16:43 sbinsh -&amp;gt; /sbin/sh&lt;BR /&gt;# ./pru.sh&lt;BR /&gt;-a&lt;BR /&gt;-e&lt;BR /&gt;-h&lt;BR /&gt;-L&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Mon, 05 Apr 2004 09:50:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239856#M714608</guid>
      <dc:creator>Ester Saez</dc:creator>
      <dc:date>2004-04-05T09:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Expressions doubt</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239857#M714609</link>
      <description>There is no difference as your output also proves.&lt;BR /&gt;&lt;BR /&gt;sks</description>
      <pubDate>Mon, 05 Apr 2004 09:59:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/conditional-expressions-doubt/m-p/3239857#M714609</guid>
      <dc:creator>Sanjay Kumar Suri</dc:creator>
      <dc:date>2004-04-05T09:59:42Z</dc:date>
    </item>
  </channel>
</rss>

