<?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 issue: parameter substitution in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070878#M94928</link>
    <description>&lt;A href="http://wwwhome.cs.utwente.nl/~broekjg/bsc/scripts/phase2.txt" target="_blank"&gt;http://wwwhome.cs.utwente.nl/~broekjg/bsc/scripts/phase2.txt&lt;/A&gt;</description>
    <pubDate>Wed, 26 Sep 2007 06:56:47 GMT</pubDate>
    <dc:creator>AwadheshPandey</dc:creator>
    <dc:date>2007-09-26T06:56:47Z</dc:date>
    <item>
      <title>shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070868#M94918</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I'm using the ${#} to check lexicographycally an IP address:&lt;BR /&gt;&lt;BR /&gt;IP=192.112&lt;BR /&gt;echo "${IP%+([0-9].+([0-9])}"&lt;BR /&gt;19&lt;BR /&gt;&lt;BR /&gt;Why does the pattern +([0-9]) remove just ONE digit from the first number while those same pattern removes all digits from the second number ?&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Sep 2007 03:03:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070868#M94918</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2007-09-26T03:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070869#M94919</link>
      <description>Hello Oscar,&lt;BR /&gt;&lt;BR /&gt;Tested in a HP-UX 11.11 OS:&lt;BR /&gt;&lt;BR /&gt;# echo $SHELL&lt;BR /&gt;/sbin/sh&lt;BR /&gt;&lt;BR /&gt;# IP=192.112                   &lt;BR /&gt;&lt;BR /&gt;# echo "${IP%+([0-9].+([0-9])}"&lt;BR /&gt;192.112&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 26 Sep 2007 03:28:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070869#M94919</guid>
      <dc:creator>TY 007</dc:creator>
      <dc:date>2007-09-26T03:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070870#M94920</link>
      <description>In my 11.23 box it's working fine with POSIX shell:&lt;BR /&gt;&lt;BR /&gt;# IP=192.112&lt;BR /&gt;# echo "${IP%+([0-9].+([0-9])}"&lt;BR /&gt;192.112&lt;BR /&gt;&lt;BR /&gt;Best regards.&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Sep 2007 03:32:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070870#M94920</guid>
      <dc:creator>J. Bravo</dc:creator>
      <dc:date>2007-09-26T03:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070871#M94921</link>
      <description>Hello Oscar,&lt;BR /&gt;&lt;BR /&gt;Tested as well in HP-UX 11.00 OS.&lt;BR /&gt;&lt;BR /&gt;# uname -r&lt;BR /&gt;B.11.00&lt;BR /&gt;&lt;BR /&gt;# echo $SHELL&lt;BR /&gt;/sbin/sh&lt;BR /&gt;&lt;BR /&gt;# IP=192.112 &lt;BR /&gt;&lt;BR /&gt;# echo "${IP%+([0-9].+([0-9])}"&lt;BR /&gt;192.112&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 26 Sep 2007 04:01:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070871#M94921</guid>
      <dc:creator>TY 007</dc:creator>
      <dc:date>2007-09-26T04:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070872#M94922</link>
      <description>I'm sorry but my patter posted here has a missing character ')', i.e., it's wrong.&lt;BR /&gt;&lt;BR /&gt;Try this next one:&lt;BR /&gt;&lt;BR /&gt;echo "${IP%+([0-9]).+([0-9])}"</description>
      <pubDate>Wed, 26 Sep 2007 04:24:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070872#M94922</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2007-09-26T04:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070873#M94923</link>
      <description>Oscar!!&lt;BR /&gt;&lt;BR /&gt;Can you clear what actually you want to print?&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Awadhesh&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Sep 2007 04:35:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070873#M94923</guid>
      <dc:creator>AwadheshPandey</dc:creator>
      <dc:date>2007-09-26T04:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070874#M94924</link>
      <description>#  IP=192.112&lt;BR /&gt;#  echo "${IP%+([0-9]).+([0-9])}"&lt;BR /&gt;19&lt;BR /&gt;# uname -r&lt;BR /&gt;B.11.11&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Wed, 26 Sep 2007 05:10:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070874#M94924</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2007-09-26T05:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070875#M94925</link>
      <description>Hello Oscar,&lt;BR /&gt;&lt;BR /&gt;# IP=192.112&lt;BR /&gt;&lt;BR /&gt;# AA=`echo $IP | awk -F. '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;# echo "${AA%+([0-9])}"&lt;BR /&gt;19&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 26 Sep 2007 05:42:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070875#M94925</guid>
      <dc:creator>TY 007</dc:creator>
      <dc:date>2007-09-26T05:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070876#M94926</link>
      <description>Hello Oscar,&lt;BR /&gt;&lt;BR /&gt;# IP=192.112&lt;BR /&gt;&lt;BR /&gt;# BB=`echo $IP | awk -F. '{print $2}'`&lt;BR /&gt;&lt;BR /&gt;# echo "${BB%+([0-9])}"&lt;BR /&gt;11&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 26 Sep 2007 05:44:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070876#M94926</guid>
      <dc:creator>TY 007</dc:creator>
      <dc:date>2007-09-26T05:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070877#M94927</link>
      <description>Hi Oscar:&lt;BR /&gt;&lt;BR /&gt;# echo "${IP%\.*}"&lt;BR /&gt;192&lt;BR /&gt;&lt;BR /&gt;# echo "${IP##[0-9]*\.}"&lt;BR /&gt;112&lt;BR /&gt;&lt;BR /&gt;You should escape the dot which otherwise means any character.  &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 26 Sep 2007 06:48:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070877#M94927</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-09-26T06:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070878#M94928</link>
      <description>&lt;A href="http://wwwhome.cs.utwente.nl/~broekjg/bsc/scripts/phase2.txt" target="_blank"&gt;http://wwwhome.cs.utwente.nl/~broekjg/bsc/scripts/phase2.txt&lt;/A&gt;</description>
      <pubDate>Wed, 26 Sep 2007 06:56:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070878#M94928</guid>
      <dc:creator>AwadheshPandey</dc:creator>
      <dc:date>2007-09-26T06:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070879#M94929</link>
      <description># echo "${IP%+([0-9]).+([0-9])}"&lt;BR /&gt;&lt;BR /&gt;In the above expression the shell is doing what it has been asked of; delete the shortest matching pattern as a single percent sign was specified. On the other hand if the expression was:&lt;BR /&gt;&lt;BR /&gt;# echo "${IP%%+([0-9]).+([0-9])}"&lt;BR /&gt;&lt;BR /&gt;...then it deletes the longest matching pattern which is the entire string as a double percent sign was specified. See the sh-posix(1) man page for details.&lt;BR /&gt;&lt;BR /&gt;~cheers</description>
      <pubDate>Wed, 26 Sep 2007 11:00:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070879#M94929</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-09-26T11:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070880#M94930</link>
      <description>&amp;gt;JRF: You should escape the dot which otherwise means any character.&lt;BR /&gt;&lt;BR /&gt;Actually no.  This is a file matching pattern not a regular expression.  In a pattern you have "*" and "?".</description>
      <pubDate>Thu, 27 Sep 2007 04:38:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070880#M94930</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-09-27T04:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070881#M94931</link>
      <description>&lt;!--!*#--&gt;Some explanations:&lt;BR /&gt;&lt;BR /&gt;    I'm trying to check lexicographically an IP address.&lt;BR /&gt;&lt;BR /&gt;    I'm very distrustful :-( -- I don't trust external commands as grep or awk, so I prefer to use shell internal tricks&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I know the difference of ${%} and ${%%} but in my example pattern&lt;BR /&gt;&lt;BR /&gt;echo "${IP%+([0-9]).+([0-9])}"&lt;BR /&gt;&lt;BR /&gt;I cannot understand why the same sub-pattern&lt;BR /&gt;&lt;BR /&gt;+([0-9])&lt;BR /&gt;&lt;BR /&gt;matches the full last byte (112) BUT only one digit from the first byte (192).&lt;BR /&gt;&lt;BR /&gt;Does the 'shortest length' behaviour of ${%} apply only to the sub-pattern following the character '%' ?&lt;BR /&gt;&lt;BR /&gt;Thanx in advance&lt;BR /&gt;</description>
      <pubDate>Thu, 27 Sep 2007 05:32:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070881#M94931</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2007-09-27T05:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070882#M94932</link>
      <description>&amp;gt;BUT only one digit from the first byte (192).&lt;BR /&gt;&amp;gt;Does the 'shortest length' behaviour of ${%} apply only to the sub-pattern following the character '%'?&lt;BR /&gt;&lt;BR /&gt;As Sandman said, it applies to everything.  Since the last pattern must match ALL of 112 to match the ".", it does.  But to match 192, it only has to match the shortest.&lt;BR /&gt;&lt;BR /&gt;I would suggest you trust in the grep and regular expressions.  grep/awk aren't the darkside ;-)</description>
      <pubDate>Thu, 27 Sep 2007 05:51:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070882#M94932</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-09-27T05:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070883#M94933</link>
      <description>&amp;gt;Does the 'shortest length' behaviour of ${%} apply only to the sub-pattern &lt;BR /&gt;&amp;gt;following the character '%' ?&lt;BR /&gt;&lt;BR /&gt;Yes it does...and the difference can be seen in the following constructs...&lt;BR /&gt;&lt;BR /&gt;# IP=192.112&lt;BR /&gt;# echo "${IP%+([0-9])}"&lt;BR /&gt;192.11&lt;BR /&gt;# echo "${IP%%+([0-9])}"&lt;BR /&gt;192.</description>
      <pubDate>Thu, 27 Sep 2007 09:45:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070883#M94933</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-09-27T09:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: shell issue: parameter substitution</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070884#M94934</link>
      <description>thanx</description>
      <pubDate>Fri, 28 Sep 2007 04:03:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-issue-parameter-substitution/m-p/5070884#M94934</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2007-09-28T04:03:02Z</dc:date>
    </item>
  </channel>
</rss>

