Andre Poenitz wrote:

> On Thu, Jan 30, 2003 at 11:55:07AM +0000, Angus Leeming wrote:
>> > Concerning cheapness:
>> > 
>> > y=${x%<*}

y=`echo $x | cut -d '<' -f 1`

>> > translator=${y#*}

translator=`echo $y | cut -d ' ' -f 2-`

>> > y=${x#*<}

y=`echo $x | cut -d '<' -f 2`

>> > email=${y%>*}

email=`echo $y | cut -d '>' -f 1`

Got it. I can do conditional substitution like this with vanilla sh 
but neither '%' nor '#' operations are available to me. Shame, they 
_are_ really nice.

>> Never seen nothing like this. Can you explain it to me? It looks
>> like gook to me ;-)
> 
> man bash
> /##
> 
>        ${parameter#word}
>        ${parameter##word}
>               The  word  is expanded to produce a pattern just as
>               in pathname expansion.  If the pattern matches  the
>               beginning  of  the  value  of  parameter,  then the
>               result of the expansion is the  expanded  value  of
>               parameter  with  the shortest matching pattern (the
>               ``#'' case) or the longest  matching  pattern  (the
>               ``##''  case) deleted. [...]
> 
> I learned about it only a few weeks ago and I _really_ like it.
> Using bash is no restriction for me.
> 
> 
>> Give me a little example of it in action and I'll try it here with
>> dumn old vanilla sh.
> 
> I don't think  sh  will work.
> 
> Andre'
> 

-- 
Angus

Reply via email to