From owner-freebsd-questions Tue Feb 19 23:10:36 2002 Delivered-To: freebsd-questions@freebsd.org Received: from chen.org.nz (adsl-210.54.19.51.quicksilver.net.nz [210.54.19.51]) by hub.freebsd.org (Postfix) with ESMTP id A28A537B402 for ; Tue, 19 Feb 2002 23:10:32 -0800 (PST) Received: (from jonc@localhost) by chen.org.nz (8.11.6/8.11.6) id g1K7AQf53711; Wed, 20 Feb 2002 20:10:26 +1300 (NZDT) (envelope-from jonc) Date: Wed, 20 Feb 2002 20:10:26 +1300 From: Jonathan Chen To: Eric Boucher Cc: FreeBSD Subject: Re: Bourne shell programming problem Message-ID: <20020220201026.A53598@grimoire.chen.org.nz> References: <20020220060104.49523.qmail@web9407.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i 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 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 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. Use basename(1): ~,8:09pm> basename /toto/tata/foo foo and you can prepend the '/' to your result. -- Jonathan Chen ---------------------------------------------------------------------- "With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead." -- RFC 1925 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message