<?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: Parameter substitution in shell: does ${##} work ? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010050#M99124</link>
    <description>Hi (again) Cas:&lt;BR /&gt;&lt;BR /&gt;Ok, that's obvious in retrospect.  We haven't nor can't anchor to the beginning of the string.  I hadn't paid attention to that.&lt;BR /&gt;&lt;BR /&gt;Using 'typeset' keeps things shell-bound:&lt;BR /&gt;&lt;BR /&gt;# typeset -LZ N=0000034;echo ${N}&lt;BR /&gt;34&lt;BR /&gt;&lt;BR /&gt;# typeset -LZ N=1000034;echo ${N}&lt;BR /&gt;1000034&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Tue, 24 Oct 2006 07:50:53 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2006-10-24T07:50:53Z</dc:date>
    <item>
      <title>Parameter substitution in shell: does ${##} work ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010043#M99117</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Let be a numeric value into a shell variable:&lt;BR /&gt;&lt;BR /&gt;N=000034&lt;BR /&gt;&lt;BR /&gt;I'm interested in removing leading zeroes.&lt;BR /&gt;According to man pages, sh-posix can do this task by means of ${N##0}:&lt;BR /&gt;&lt;BR /&gt;echo ${N#0}  # removes only one leading zero&lt;BR /&gt;echo ${N##0} # removes all leading zeroes&lt;BR /&gt;&lt;BR /&gt;but in my case, that doesn't work:&lt;BR /&gt;&lt;BR /&gt;${N##0} works as ${N#0}, i.e, only one leading zero is removed in both cases.&lt;BR /&gt;&lt;BR /&gt;Can anyone help me ?&lt;BR /&gt;&lt;BR /&gt;P.D: I'd prefer this shell trick rather than using an external command.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 24 Oct 2006 05:57:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010043#M99117</guid>
      <dc:creator>CAS_2</dc:creator>
      <dc:date>2006-10-24T05:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter substitution in shell: does ${##} work ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010044#M99118</link>
      <description>Hi,&lt;BR /&gt;N="000034"&lt;BR /&gt;N2=`expr $N + 0`&lt;BR /&gt;echo $N2&lt;BR /&gt;34</description>
      <pubDate>Tue, 24 Oct 2006 06:09:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010044#M99118</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-10-24T06:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter substitution in shell: does ${##} work ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010045#M99119</link>
      <description>Hi (again),&lt;BR /&gt;also found:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=61952" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=61952&lt;/A&gt;</description>
      <pubDate>Tue, 24 Oct 2006 06:13:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010045#M99119</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-10-24T06:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter substitution in shell: does ${##} work ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010046#M99120</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;$ N=000034&lt;BR /&gt;$ echo ${N##*0}&lt;BR /&gt;34&lt;BR /&gt;&lt;BR /&gt;For more information on parameter substitution:&lt;BR /&gt;&lt;A href="http://docs.hp.com/en/B2355-90046/ch19s03.html#d0e17999" target="_blank"&gt;http://docs.hp.com/en/B2355-90046/ch19s03.html#d0e17999&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Tue, 24 Oct 2006 06:43:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010046#M99120</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-10-24T06:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter substitution in shell: does ${##} work ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010047#M99121</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;# N=000034&lt;BR /&gt;# X=${N##*0}&lt;BR /&gt;# echo $X&lt;BR /&gt;&lt;BR /&gt;Note the splat ("*") following the "##".&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 24 Oct 2006 06:50:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010047#M99121</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-10-24T06:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter substitution in shell: does ${##} work ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010048#M99122</link>
      <description>Hello&lt;BR /&gt;&lt;BR /&gt;Indeed right your are:&lt;BR /&gt;use typeset -i N=000034&lt;BR /&gt;&lt;BR /&gt;It seems without interger the '*' but '?'&lt;BR /&gt;comes to the rescue :&lt;BR /&gt;see examples:&lt;BR /&gt;&lt;BR /&gt;[vwbsrv3:/d]# print ${N##*0}&lt;BR /&gt;34&lt;BR /&gt;[vwbsrv3:/]# print ${N##?0}&lt;BR /&gt;0034&lt;BR /&gt;[vwbsrv3:/]# print ${N##??0}&lt;BR /&gt;034&lt;BR /&gt;[vwbsrv3:/]# print ${N#??0}&lt;BR /&gt;034&lt;BR /&gt;-No difference here&lt;BR /&gt;&lt;BR /&gt;[vwbsrv3:/]# print ${N##???0}&lt;BR /&gt;34&lt;BR /&gt;[vwbsrv3:/stand/build]#&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But when you make it a INTEGER,&lt;BR /&gt;&lt;BR /&gt;[vwbsrv3:/stand/build]# typeset -i N=00034&lt;BR /&gt;[vwbsrv3:/stand/build]# print ${N##*0}&lt;BR /&gt;34&lt;BR /&gt;[vwbsrv3:/stand/build]# print ${N##0}&lt;BR /&gt;34&lt;BR /&gt;&lt;BR /&gt;It works:</description>
      <pubDate>Tue, 24 Oct 2006 07:01:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010048#M99122</guid>
      <dc:creator>Frank de Vries</dc:creator>
      <dc:date>2006-10-24T07:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter substitution in shell: does ${##} work ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010049#M99123</link>
      <description>James, read these examples below:&lt;BR /&gt;&lt;BR /&gt;example 1: OK&lt;BR /&gt;&lt;BR /&gt;X=00000034   &lt;BR /&gt;echo ${X##*0}&lt;BR /&gt;34&lt;BR /&gt;&lt;BR /&gt;example 2: failed&lt;BR /&gt;&lt;BR /&gt;X=50034   &lt;BR /&gt;echo ${X##*0}&lt;BR /&gt;34&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 24 Oct 2006 07:31:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010049#M99123</guid>
      <dc:creator>CAS_2</dc:creator>
      <dc:date>2006-10-24T07:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter substitution in shell: does ${##} work ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010050#M99124</link>
      <description>Hi (again) Cas:&lt;BR /&gt;&lt;BR /&gt;Ok, that's obvious in retrospect.  We haven't nor can't anchor to the beginning of the string.  I hadn't paid attention to that.&lt;BR /&gt;&lt;BR /&gt;Using 'typeset' keeps things shell-bound:&lt;BR /&gt;&lt;BR /&gt;# typeset -LZ N=0000034;echo ${N}&lt;BR /&gt;34&lt;BR /&gt;&lt;BR /&gt;# typeset -LZ N=1000034;echo ${N}&lt;BR /&gt;1000034&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 24 Oct 2006 07:50:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010050#M99124</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-10-24T07:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter substitution in shell: does ${##} work ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010051#M99125</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;# N1=0000034&lt;BR /&gt;# N2=50034&lt;BR /&gt;# echo $N1&lt;BR /&gt;0000034&lt;BR /&gt;# echo $N2&lt;BR /&gt;50034&lt;BR /&gt;# echo $(( 10#$N1 ))&lt;BR /&gt;34&lt;BR /&gt;# echo $(( 10#$N2 ))&lt;BR /&gt;50034&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Tue, 24 Oct 2006 08:04:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010051#M99125</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2006-10-24T08:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter substitution in shell: does ${##} work ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010052#M99126</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;if you really cannot use a typeset because of restrictions in the value, your variables are set, this will do it:&lt;BR /&gt;&lt;BR /&gt;X=00000034 &lt;BR /&gt;print ${X#${X%%[1-9]*}}&lt;BR /&gt;34&lt;BR /&gt;&lt;BR /&gt;X=00010034&lt;BR /&gt;print ${X#${X%%[1-9]*}}&lt;BR /&gt;10034&lt;BR /&gt;&lt;BR /&gt;X=500000034 &lt;BR /&gt;print ${X#${X%%[1-9]*}}&lt;BR /&gt;500000034&lt;BR /&gt;&lt;BR /&gt;The trick is, to determine the number of leading zeros (if any exist) first.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Tue, 24 Oct 2006 08:38:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010052#M99126</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-10-24T08:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter substitution in shell: does ${##} work ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010053#M99127</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;/&amp;gt; X=00000034&lt;BR /&gt;/&amp;gt; echo $X&lt;BR /&gt;00000034&lt;BR /&gt;/&amp;gt; X=$(( X+0 ))&lt;BR /&gt;/&amp;gt; echo $X&lt;BR /&gt;&lt;BR /&gt;the rtick is to add 0 to force the varibale to be an integer. In this way the leading zeros will be removed.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Wed, 25 Oct 2006 03:03:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010053#M99127</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2006-10-25T03:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter substitution in shell: does ${##} work ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010054#M99128</link>
      <description>Thanks, Peter</description>
      <pubDate>Wed, 25 Oct 2006 03:25:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/parameter-substitution-in-shell-does-work/m-p/5010054#M99128</guid>
      <dc:creator>CAS_2</dc:creator>
      <dc:date>2006-10-25T03:25:10Z</dc:date>
    </item>
  </channel>
</rss>

