bash question

William Park opengeometry-FFYn/CNdgSA at public.gmane.org
Thu Aug 12 15:44:50 UTC 2004


On Wed, Aug 11, 2004 at 12:46:54AM -0400, Peter L. Peres wrote:
> 
> I was trying to use ${foo:-1:2} in bash but it does not work (it is 
> supposed to extract the last 2 chars in $foo. However ${foo:${#foo}-2:2} 
> works as expected.

Use ${foo: -2}.  Note the space, because ${foo:-xxx} has some other well
defined meaning.

-- 
William Park <opengeometry-FFYn/CNdgSA at public.gmane.org>
Open Geometry Consulting, Toronto, Canada
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list