<?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: Issue with &amp;quot;if&amp;quot; statement in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/issue-with-quot-if-quot-statement/m-p/3913318#M96892</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I know that when I have anything in square brackets I have to make sure to have a space after the first and a space before the last or I get errors.&lt;BR /&gt;&lt;BR /&gt;IE: [-f file.txt]  &amp;lt;- I can't do this&lt;BR /&gt;&lt;BR /&gt;    [ -f file.txt ] &amp;lt;- this works&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 14 Dec 2006 14:42:13 GMT</pubDate>
    <dc:creator>Coolmar</dc:creator>
    <dc:date>2006-12-14T14:42:13Z</dc:date>
    <item>
      <title>Issue with "if" statement</title>
      <link>https://community.hpe.com/t5/operating-system-linux/issue-with-quot-if-quot-statement/m-p/3913317#M96891</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;We are using below given "if" statement in one of our UNIX sh scripts.&lt;BR /&gt;&lt;BR /&gt;if [ -f ${DIR}/Suspect_* -o -f ${DIR}/Prospect_* -o -f ${DIR}/Contact_* -o -f ${DIR}/Activity_* ]&lt;BR /&gt;then&lt;BR /&gt;echo "Yes"&lt;BR /&gt;else&lt;BR /&gt;echo "No"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;But it gives foolowing syntax error. &lt;BR /&gt;"ksh: test: syntax error"&lt;BR /&gt;&lt;BR /&gt;But it is also observed that same sh script runs fine on other UNIX server.&lt;BR /&gt;&lt;BR /&gt;when the above given "if" statement is changed to as given below it runs fine.&lt;BR /&gt;&lt;BR /&gt;if [ -f ${DIR}/Suspect_* ] || [ -f ${DIR}/Prospect_* ] || [ -f ${DIR}/Contact_* ] || [ -f ${DIR}/Activity_* ]&lt;BR /&gt;then&lt;BR /&gt;echo "Yes"&lt;BR /&gt;else&lt;BR /&gt;echo "No"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;What could be the issue? Why would one command run fine on one server and not on other?&lt;BR /&gt;&lt;BR /&gt;Please provide any information related to this.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Dec 2006 14:37:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/issue-with-quot-if-quot-statement/m-p/3913317#M96891</guid>
      <dc:creator>Kalpesh Jaywant Mhatre</dc:creator>
      <dc:date>2006-12-14T14:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with "if" statement</title>
      <link>https://community.hpe.com/t5/operating-system-linux/issue-with-quot-if-quot-statement/m-p/3913318#M96892</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I know that when I have anything in square brackets I have to make sure to have a space after the first and a space before the last or I get errors.&lt;BR /&gt;&lt;BR /&gt;IE: [-f file.txt]  &amp;lt;- I can't do this&lt;BR /&gt;&lt;BR /&gt;    [ -f file.txt ] &amp;lt;- this works&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Dec 2006 14:42:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/issue-with-quot-if-quot-statement/m-p/3913318#M96892</guid>
      <dc:creator>Coolmar</dc:creator>
      <dc:date>2006-12-14T14:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with "if" statement</title>
      <link>https://community.hpe.com/t5/operating-system-linux/issue-with-quot-if-quot-statement/m-p/3913319#M96893</link>
      <description>different os'es, patches, shells, version of shells could all impact what runs where. &lt;BR /&gt;&lt;BR /&gt;now, my question to you is, does the second version work properly on the first server?</description>
      <pubDate>Thu, 14 Dec 2006 15:12:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/issue-with-quot-if-quot-statement/m-p/3913319#M96893</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2006-12-14T15:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with "if" statement</title>
      <link>https://community.hpe.com/t5/operating-system-linux/issue-with-quot-if-quot-statement/m-p/3913320#M96894</link>
      <description>You shouldn't use shell globs (the * character) in your test. It probably won't work how you expect it to.&lt;BR /&gt;&lt;BR /&gt;If you have a Suspect_1 and a Suspect_2, that would expand to "if [ -f Suspect_1 Suspect_2 -o ... ]", which isn't valid syntax. However, "if [ -f Suspect_1 Suspect_2 ]" will work fine because test will just ignore everything after the first filename (at least on HP-UX). And, of course, if you have exactly one matching file it works either way.&lt;BR /&gt;&lt;BR /&gt;If you don't have any Suspect_* files, it could be evaluated as a blank or as the literal string "Suspect_*", depending on which shell you're using and what options are set. That's probably not what you want, but it just happens to work in HP's sh and ksh.&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Dec 2006 17:11:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/issue-with-quot-if-quot-statement/m-p/3913320#M96894</guid>
      <dc:creator>Heironimus</dc:creator>
      <dc:date>2006-12-14T17:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with "if" statement</title>
      <link>https://community.hpe.com/t5/operating-system-linux/issue-with-quot-if-quot-statement/m-p/3913321#M96895</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;in addition to the remarks of  Heironimus:&lt;BR /&gt;You CAN use filename pattern as argument in a test statement in the ksh, when you change&lt;BR /&gt;[ .. ]  to  [[ ... ]]&lt;BR /&gt;Check the manpage for the correct syntax!&lt;BR /&gt;Changing your example to&lt;BR /&gt;&lt;BR /&gt;if [[ -f ${DIR}/Suspect_* || -f ${DIR}/Prospect_* || -f ${DIR}/Contact_* || -f ${DIR}/Activity_* ]]&lt;BR /&gt;then ...&lt;BR /&gt;&lt;BR /&gt;should do it.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 15 Dec 2006 07:16:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/issue-with-quot-if-quot-statement/m-p/3913321#M96895</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-12-15T07:16:24Z</dc:date>
    </item>
  </channel>
</rss>

