<?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: shell scripting - test for similarity in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792153#M265221</link>
    <description>hi,&lt;BR /&gt;&lt;BR /&gt;for wildcard, use the "case" instead of "if-then".&lt;BR /&gt;&lt;BR /&gt;GOOD LUCK!!</description>
    <pubDate>Mon, 22 May 2006 04:59:32 GMT</pubDate>
    <dc:creator>Warren_9</dc:creator>
    <dc:date>2006-05-22T04:59:32Z</dc:date>
    <item>
      <title>shell scripting - test for similarity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792149#M265217</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;how does one test for similarity in shell scripting? "If" doesn't seem to accept wildcards.&lt;BR /&gt;&lt;BR /&gt;I want something like, if the string is similar to Lo1, Lo2, Lo, then do something&lt;BR /&gt;&lt;BR /&gt;I tried&lt;BR /&gt;&lt;BR /&gt;if &lt;BR /&gt;[ $string = Lo* ]&lt;BR /&gt;then&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;Its simple in perl, but here I have a shell script to modify.&lt;BR /&gt;&lt;BR /&gt;-Alvi</description>
      <pubDate>Mon, 22 May 2006 04:33:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792149#M265217</guid>
      <dc:creator>Omar Alvi_1</dc:creator>
      <dc:date>2006-05-22T04:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: shell scripting - test for similarity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792150#M265218</link>
      <description>Try putting it in double quotes (")</description>
      <pubDate>Mon, 22 May 2006 04:41:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792150#M265218</guid>
      <dc:creator>Vibhor Kumar Agarwal</dc:creator>
      <dc:date>2006-05-22T04:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: shell scripting - test for similarity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792151#M265219</link>
      <description>Hi Omar,&lt;BR /&gt;&lt;BR /&gt;You use "case" statement instead of "if-then".&lt;BR /&gt;&lt;BR /&gt;case $string in&lt;BR /&gt;Lo1)  execute&lt;BR /&gt;;;&lt;BR /&gt;Lo2) execute1&lt;BR /&gt;;;&lt;BR /&gt;L0*) execute2&lt;BR /&gt;;;&lt;BR /&gt;A|a) execute3;;&lt;BR /&gt;&lt;BR /&gt;*) execute4&lt;BR /&gt;;;&lt;BR /&gt;esac&lt;BR /&gt;Hope this server your purpose.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Rajesh SB&lt;BR /&gt;</description>
      <pubDate>Mon, 22 May 2006 04:48:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792151#M265219</guid>
      <dc:creator>Rajesh SB</dc:creator>
      <dc:date>2006-05-22T04:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: shell scripting - test for similarity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792152#M265220</link>
      <description>Why not try &lt;BR /&gt;&lt;BR /&gt;if [ $String = Lo1 ] &amp;amp;&amp;amp; [ $string = Lo2 ]&lt;BR /&gt;&lt;BR /&gt;Chan&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 22 May 2006 04:49:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792152#M265220</guid>
      <dc:creator>Chan 007</dc:creator>
      <dc:date>2006-05-22T04:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: shell scripting - test for similarity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792153#M265221</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;for wildcard, use the "case" instead of "if-then".&lt;BR /&gt;&lt;BR /&gt;GOOD LUCK!!</description>
      <pubDate>Mon, 22 May 2006 04:59:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792153#M265221</guid>
      <dc:creator>Warren_9</dc:creator>
      <dc:date>2006-05-22T04:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: shell scripting - test for similarity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792154#M265222</link>
      <description>Why dont' you use the substring function of if.&lt;BR /&gt;&lt;BR /&gt;I dont' remember how its exactly written.&lt;BR /&gt;Check out the man pages.</description>
      <pubDate>Mon, 22 May 2006 05:17:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792154#M265222</guid>
      <dc:creator>Vibhor Kumar Agarwal</dc:creator>
      <dc:date>2006-05-22T05:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: shell scripting - test for similarity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792155#M265223</link>
      <description>Hi Alvi,&lt;BR /&gt;&lt;BR /&gt;you can grep for a pattern at the beginning of a string, e.g.:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;PAR="$1"&lt;BR /&gt;PATTERN="Lo"&lt;BR /&gt;echo "$1" | grep -q ^"$PATTERN"&lt;BR /&gt;if [ $? = "0" ]&lt;BR /&gt;then&lt;BR /&gt;        echo hit&lt;BR /&gt;else&lt;BR /&gt;        echo no hit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;try the above with your string to compare as $1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Mon, 22 May 2006 06:41:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792155#M265223</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2006-05-22T06:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: shell scripting - test for similarity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792156#M265224</link>
      <description>The single [] uses the command test (do man test). The [[]] uses a conditional tester that is part of ksh/posix-sh. Try with the 2 square bracket test-&lt;BR /&gt; &lt;BR /&gt;if [[ $string = Lo* ]]&lt;BR /&gt;then&lt;BR /&gt;exit&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 22 May 2006 09:26:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792156#M265224</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2006-05-22T09:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: shell scripting - test for similarity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792157#M265225</link>
      <description>Thank you all for the suggestions.&lt;BR /&gt;&lt;BR /&gt;The case and grep ideas worked perfectly. The if substring thing, though, I didn't get.&lt;BR /&gt;&lt;BR /&gt;And Rodney, the double square brackets, exactly what I was looking for. &lt;BR /&gt;&lt;BR /&gt;Thanks and Regards,&lt;BR /&gt;&lt;BR /&gt;-Alvi</description>
      <pubDate>Tue, 23 May 2006 02:14:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting-test-for-similarity/m-p/3792157#M265225</guid>
      <dc:creator>Omar Alvi_1</dc:creator>
      <dc:date>2006-05-23T02:14:21Z</dc:date>
    </item>
  </channel>
</rss>

