Date: Tue, 19 Feb 2002 23:44:05 -0800 From: "Crist J. Clark" <cjc@FreeBSD.ORG> To: Eric Boucher <eric_boucher60@yahoo.com> Cc: FreeBSD <freebsd-questions@FreeBSD.ORG> Subject: Re: Bourne shell programming problem Message-ID: <20020219234405.V48401@blossom.cjclark.org> In-Reply-To: <20020220060104.49523.qmail@web9407.mail.yahoo.com>; from eric_boucher60@yahoo.com on Tue, Feb 19, 2002 at 10:01:04PM -0800 References: <20020220060104.49523.qmail@web9407.mail.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Feb 19, 2002 at 10:01:04PM -0800, Eric Boucher wrote: > Hi everyone, > > I'm doing a little bourne shell program that makes > something installed automatically on my FreeBSD. But I > have a little problem: I want to be able to read every > caracter of a variable. For example: Suppose I have a > variale named TOTO and the content of TOTO is > "/toto/tata/foo". So if I do an echo the ouput is: > echo $TOTO > /toto/tata/foo > > What I'm trying to do is to catch only "/foo" and put > it in another variable. So I tought that if someone > tell me how to read each caracter, I can loop over > each caracter, remember the positition of the last "/" > and then take all the caracters after that "/" and put > it in a variable. You've gotten a couple of answers, so why not one more? Do it all with builtin sh(1) abilities, $ TOTO=/toto/tata/foo $ echo "/${TOTO##*/}" /foo -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020219234405.V48401>