From owner-freebsd-questions Wed Feb 20 6:36:56 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mail7.carolina.rr.com (fe7.southeast.rr.com [24.93.67.54]) by hub.freebsd.org (Postfix) with ESMTP id 4A88737B41A for ; Wed, 20 Feb 2002 06:36:45 -0800 (PST) Received: from snafu.enterit.com ([66.57.159.198]) by mail7.carolina.rr.com with Microsoft SMTPSVC(5.5.1877.687.68); Wed, 20 Feb 2002 01:36:47 -0500 Message-Id: <5.1.0.14.0.20020220015922.02ba4ca0@mail.enterit.com> X-Sender: jconner@enterit.com@mail.enterit.com X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Wed, 20 Feb 2002 02:00:38 -0500 To: Gilad Rom From: Jim Conner Subject: Re: Bourne shell programming problem Cc: Eric Boucher , FreeBSD-Questions In-Reply-To: <1014185310.23322.14.camel@dhcp-251.meshek.eh> References: <20020220060104.49523.qmail@web9407.mail.yahoo.com> <20020220060104.49523.qmail@web9407.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG At 08:08 02.20.2002 +0200, Gilad Rom wrote: >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 > > > > 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. > > If foo is a file I'd use /usr/bin/basename var="/toto/tata/foo" base=$(/usr/bin/basename $var) - Jim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message