Date: 20 Feb 2002 08:08:27 +0200 From: Gilad Rom <rom_glsa@ein-hashofet.co.il> To: Eric Boucher <eric_boucher60@yahoo.com> Cc: FreeBSD-Questions <freebsd-questions@FreeBSD.ORG> Subject: Re: Bourne shell programming problem Message-ID: <1014185310.23322.14.camel@dhcp-251.meshek.eh> In-Reply-To: <20020220060104.49523.qmail@web9407.mail.yahoo.com> References: <20020220060104.49523.qmail@web9407.mail.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
What you want to do is harness the power of awk: var="/toto/tata/foo" dirs=`echo $var | awk -F '/' '{print $1 $2 $3;}'` for i in $dirs do echo $i done Gilad On Wed, 2002-02-20 at 08:01, 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. > > Can somebody help me on this one? I hope I'm > sufficiently clear. > > Thanks > > Eric > > __________________________________________________ > Do You Yahoo!? > Yahoo! Sports - Coverage of the 2002 Olympic Games > http://sports.yahoo.com > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message > 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?1014185310.23322.14.camel>