<?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 ! not working in ksh in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961173#M95101</link>
    <description>Hi:&lt;BR /&gt;&lt;BR /&gt;This should be:&lt;BR /&gt;&lt;BR /&gt;if [ `grep -c "Synchronizing" $STATE` -eq 0 ]&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;That is, it appears that you want to test whether or not there are any occurances of "Synchronizing" in the (file) ${STATE}.&lt;BR /&gt;&lt;BR /&gt;Another way is to examine the return value of grep (zero meaning that there *is* a match):&lt;BR /&gt;&lt;BR /&gt;# grep "Synchronizing" ${STATE} &amp;amp;&amp;amp; echo "yes" || echo "no"&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Tue, 13 Mar 2007 17:24:15 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2007-03-13T17:24:15Z</dc:date>
    <item>
      <title>if ! not working in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961170#M95098</link>
      <description>This is 11.0, N class machine.&lt;BR /&gt;&lt;BR /&gt;I can get the following to work on the command line if I type it in, but not in a script. In a script, it complains about the "!".&lt;BR /&gt;The script starts with #!/bin/ksh.&lt;BR /&gt;Why is that, is there a bug?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if ! grep "Synchronizing" $STATE&lt;BR /&gt;then&lt;BR /&gt;        echo not&lt;BR /&gt;else&lt;BR /&gt;        echo yes&lt;BR /&gt;fi</description>
      <pubDate>Tue, 13 Mar 2007 16:51:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961170#M95098</guid>
      <dc:creator>dictum9</dc:creator>
      <dc:date>2007-03-13T16:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: if ! not working in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961171#M95099</link>
      <description>most likely need some quoting...&lt;BR /&gt;&lt;BR /&gt;other option&lt;BR /&gt;&lt;BR /&gt;if grep "Syncronizing" $STATE&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;</description>
      <pubDate>Tue, 13 Mar 2007 17:01:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961171#M95099</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2007-03-13T17:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: if ! not working in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961172#M95100</link>
      <description>Now that I think more..&lt;BR /&gt;&lt;BR /&gt;I do not think you can use "if !"&lt;BR /&gt;&lt;BR /&gt;typically you would either "if true" or "if false".  Not "if not true."&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Mar 2007 17:12:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961172#M95100</guid>
      <dc:creator>Tim Nelson</dc:creator>
      <dc:date>2007-03-13T17:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: if ! not working in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961173#M95101</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;This should be:&lt;BR /&gt;&lt;BR /&gt;if [ `grep -c "Synchronizing" $STATE` -eq 0 ]&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;That is, it appears that you want to test whether or not there are any occurances of "Synchronizing" in the (file) ${STATE}.&lt;BR /&gt;&lt;BR /&gt;Another way is to examine the return value of grep (zero meaning that there *is* a match):&lt;BR /&gt;&lt;BR /&gt;# grep "Synchronizing" ${STATE} &amp;amp;&amp;amp; echo "yes" || echo "no"&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 13 Mar 2007 17:24:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961173#M95101</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-03-13T17:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: if ! not working in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961174#M95102</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Ooops.  The last suggestion is best done with the '-q'uiet switch (since you don't want the output; only the success or failure of the match:&lt;BR /&gt;&lt;BR /&gt;# grep -q Synchronizing ${STATE} &amp;amp;&amp;amp; echo yes || echo no&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Mar 2007 19:19:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961174#M95102</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-03-13T19:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: if ! not working in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961175#M95103</link>
      <description>&amp;gt;Tim: I do not think you can use "if !"&lt;BR /&gt;&lt;BR /&gt;Right, it is only available in [ ] or conditional expressions in [[ ]].&lt;BR /&gt;Or !(pattern-list).&lt;BR /&gt;And of course in arithmetic expressions in (( )) or let.</description>
      <pubDate>Wed, 14 Mar 2007 03:32:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961175#M95103</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-03-14T03:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: if ! not working in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961176#M95104</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;this feature is not available in the standard ksh; in the ksh93 version, it is.&lt;BR /&gt;So if you want to try, use&lt;BR /&gt;/usr/dt/bin/dtksh&lt;BR /&gt;as the shell for your script.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Wed, 14 Mar 2007 06:31:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961176#M95104</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-03-14T06:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: if ! not working in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961177#M95105</link>
      <description>&lt;!--!*#--&gt;I ended up not using "!" and reversing the if statement. &lt;BR /&gt;&lt;BR /&gt;Still not real clear as to why it works in shell but not in the script.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Mar 2007 08:41:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961177#M95105</guid>
      <dc:creator>dictum9</dc:creator>
      <dc:date>2007-03-14T08:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: if ! not working in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961178#M95106</link>
      <description>"Still not real clear as to why it works in shell but not in the script...."&lt;BR /&gt;&lt;BR /&gt;well, it would appear that the shell you work in is not ksh.&lt;BR /&gt;&lt;BR /&gt;easy test, type in /bin/ksh and then enter the command.  does it work?</description>
      <pubDate>Wed, 14 Mar 2007 11:18:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961178#M95106</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2007-03-14T11:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: if ! not working in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961179#M95107</link>
      <description>&lt;!--!*#--&gt;It is shell specific so it may depend on what you have as your #! line at the top which I suspect points at a different shell.&lt;BR /&gt;&lt;BR /&gt;"man test" is your friend for this sort of stuff.&lt;BR /&gt;&lt;BR /&gt;I tend to be a bit old school and tend to do something like:&lt;BR /&gt;&lt;BR /&gt;grep -q "some string" "some file"&lt;BR /&gt;if [ $? -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt;   echo "some string not found"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Because to me it makes it clear that it is the exit code that is being Analyzed in the conditional.&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Mar 2007 23:43:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961179#M95107</guid>
      <dc:creator>Daavid Turnbull</dc:creator>
      <dc:date>2007-03-14T23:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: if ! not working in ksh (need sh or dtksh)</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961180#M95108</link>
      <description>&lt;P&gt;&amp;gt;Peter: this feature is not available in the standard ksh&lt;BR /&gt;&lt;BR /&gt;You're right, it is highlighted on my sh-posix(1) entry. ;-)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;OldSchool: it would appear that the shell you work in is not ksh.&lt;BR /&gt;&lt;BR /&gt;Most likely, sh.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Still not real clear ... but not in the script.&lt;BR /&gt;&lt;BR /&gt;Change to: #!/bin/sh.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;Daavid: "man test" is your friend for this sort of stuff.﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not if you are using ksh or the posix shell.&amp;nbsp; And test(1) is only for stuff in [...].&lt;/P&gt;&lt;P&gt;And more importantly, test(1) just invokes the posix shell.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2011 03:54:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961180#M95108</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-10-10T03:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: if ! not working in ksh</title>
      <link>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961181#M95109</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Dennis wrote :Change to: #!/bin/sh.&lt;BR /&gt;&lt;BR /&gt;To be clear, '/bin' is a link to '/usr/bin'.  '/usr/bin/sh' is the POSIX shell in HP-UX.  The Korn-88 shell is represented by '/usr/bin/ksh' and the Korn-93 shell can be found as '/usr/dt/bin/dtksh'.  The (useless?) Bourne shell can be found as '/usr/old/bin/sh'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 15 Mar 2007 07:16:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/if-not-working-in-ksh/m-p/3961181#M95109</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-03-15T07:16:48Z</dc:date>
    </item>
  </channel>
</rss>

