On 4/3/2010 7:51 PM, John Baxter wrote:
bash:
selection=${selection#/}

as in (omitting the bash $ prompt, as it seems to confuse things when present)
selection=/home/xx/yy
selection=${selection#/}
echo $selection
home/xx/yy
selection=${selection#/}
echo $selection
home/xx/yy

Why?
${thing#pattern}
    If pattern matches the thing, delete the shortest match else do nothing.

In the second instance above, there is no match, so no change. pattern
is glob-like. ## is largest match. % and %% work on the right end of
thing.

C-like shells: I have no idea (since I hate C, I hate C-like shells).


Thanks to all for the explanations and examples. Spent years programming in Fortran and assembler but this bash stuff leaves me bewildered sometimes.

--
Thanks, Tom (retired penguin)
openSuSE 11.3-M4, kde 4.4.0
FF 3.6.0

Reply via email to