<?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: Problem with string Comparison in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833095#M100586</link>
    <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;Instead of using a regular expression with an 'if' use a 'case':&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 28 Jul 2006 17:03:26 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2006-07-28T17:03:26Z</dc:date>
    <item>
      <title>Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833088#M100579</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Sorry for such a basic question. But still don't seem to get this working.&lt;BR /&gt;&lt;BR /&gt;I get a fiename as an argument to the script and based on the file name, I need to rename it with the date appended to it. &lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;INFILE=$1&lt;BR /&gt;echo "The incoming filename is $INFILE"&lt;BR /&gt;DAYSTRING=`date +%Y%m%d`&lt;BR /&gt;TIMESTRING=`date +%H%M%S`&lt;BR /&gt;if [ "$INFILE" = "prod_h_datafile_???.txt" ]&lt;BR /&gt;then&lt;BR /&gt;  echo "Match Found"&lt;BR /&gt;  OUTFILE=${DAYSTRING}${TIMESTRING}_hvendr.sig&lt;BR /&gt;fi&lt;BR /&gt;echo "The outgoing filename is $OUTFILE"&lt;BR /&gt;&lt;BR /&gt;The script seeems to be working fine if I remove the ??? from the if statement and add the actual number. But with the ???, the comparison always fails. &lt;BR /&gt;&lt;BR /&gt;Please suggest.&lt;BR /&gt;&lt;BR /&gt;TIA&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Jul 2006 14:29:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833088#M100579</guid>
      <dc:creator>mougli</dc:creator>
      <dc:date>2006-07-28T14:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833089#M100580</link>
      <description>ksh doesn't do regexp on strings like that.&lt;BR /&gt;&lt;BR /&gt;If you do something like&lt;BR /&gt;&lt;BR /&gt;if [ $(echo $INFILE | egrep -c "prod_h_datafile_???.txt") -gt 0 ] &lt;BR /&gt;&lt;BR /&gt;then it should work.</description>
      <pubDate>Fri, 28 Jul 2006 14:43:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833089#M100580</guid>
      <dc:creator>Jonathan Fife</dc:creator>
      <dc:date>2006-07-28T14:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833090#M100581</link>
      <description>actually that doesn't work...</description>
      <pubDate>Fri, 28 Jul 2006 14:48:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833090#M100581</guid>
      <dc:creator>Jonathan Fife</dc:creator>
      <dc:date>2006-07-28T14:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833091#M100582</link>
      <description>egrep -c "prod_h_datafile...\.txt"&lt;BR /&gt;&lt;BR /&gt;there we go :)</description>
      <pubDate>Fri, 28 Jul 2006 14:51:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833091#M100582</guid>
      <dc:creator>Jonathan Fife</dc:creator>
      <dc:date>2006-07-28T14:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833092#M100583</link>
      <description>Thanks!! It worked..</description>
      <pubDate>Fri, 28 Jul 2006 14:53:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833092#M100583</guid>
      <dc:creator>mougli</dc:creator>
      <dc:date>2006-07-28T14:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833093#M100584</link>
      <description>Sorry. I think there is a problem with your answer. Now If I add similar comparison statements, it returns 0 for all of them and all the comparison are true..</description>
      <pubDate>Fri, 28 Jul 2006 15:22:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833093#M100584</guid>
      <dc:creator>mougli</dc:creator>
      <dc:date>2006-07-28T15:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833094#M100585</link>
      <description>Try &lt;BR /&gt;&lt;BR /&gt;if [ `echo ${INFILE} | grep "prod_h_datafile_[0-9]\{8\}\.txt$"` ]&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry d brown jr</description>
      <pubDate>Fri, 28 Jul 2006 15:25:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833094#M100585</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2006-07-28T15:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833095#M100586</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;Instead of using a regular expression with an 'if' use a 'case':&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Jul 2006 17:03:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833095#M100586</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-07-28T17:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833096#M100587</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;Sorry, I clicked the wrong button!&lt;BR /&gt;&lt;BR /&gt;Instead of using a regular expression with an 'if' use a 'case' statement.  Thry this version of your script:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;INFILE=$1&lt;BR /&gt;echo "The incoming filename is $INFILE"&lt;BR /&gt;DAYSTRING=`date +%Y%m%d`&lt;BR /&gt;TIMESTRING=`date +%H%M%S`&lt;BR /&gt;case $INFILE in&lt;BR /&gt;  prod_h_datafile_[0-9][0-9][0-9].txt )&lt;BR /&gt;    echo "Match Found"&lt;BR /&gt;    OUTFILE=${DAYSTRING}${TIMESTRING}_hvendr.sig&lt;BR /&gt;    ;;&lt;BR /&gt;  * )&lt;BR /&gt;    echo "NO match!"&lt;BR /&gt;    ;;&lt;BR /&gt;esac&lt;BR /&gt;echo "The outgoing filename is $OUTFILE"&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 28 Jul 2006 17:05:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833096#M100587</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-07-28T17:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833097#M100588</link>
      <description>To do pattern matching in sh/ksh you need to use [[ ]]:&lt;BR /&gt;if [[ "$INFILE" = prod_h_datafile_???.txt ]]&lt;BR /&gt;&lt;BR /&gt;Note you can't quote the pattern.</description>
      <pubDate>Fri, 28 Jul 2006 19:14:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833097#M100588</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-07-28T19:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833098#M100589</link>
      <description>Thanks Dennis. It worked.&lt;BR /&gt;&lt;BR /&gt;Regards..</description>
      <pubDate>Mon, 31 Jul 2006 10:46:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833098#M100589</guid>
      <dc:creator>mougli</dc:creator>
      <dc:date>2006-07-31T10:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833099#M100590</link>
      <description>Thanks Dennis. It worked. But is there something missing without the quotes??&lt;BR /&gt;&lt;BR /&gt;Regards..</description>
      <pubDate>Mon, 31 Jul 2006 10:46:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833099#M100590</guid>
      <dc:creator>mougli</dc:creator>
      <dc:date>2006-07-31T10:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with string Comparison</title>
      <link>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833100#M100591</link>
      <description>&lt;P&gt;&amp;gt;But is there something missing without the quotes??&lt;BR /&gt;&lt;BR /&gt;One day I was fiddling with a script and it had [[ ]] instead of [ ] and I didn't know why it failed. I assumed it was string comparison. But it is pattern matching and by experience, it doesn't allow quotes. Probably assumes the they are part of the pattern? That's why I warned you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to quote an embedded space, use "\".&lt;/P&gt;</description>
      <pubDate>Sun, 14 Aug 2011 23:11:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/problem-with-string-comparison/m-p/3833100#M100591</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-08-14T23:11:43Z</dc:date>
    </item>
  </channel>
</rss>

