Date: Wed, 20 Feb 2002 20:10:26 +1300 From: Jonathan Chen <jonc@chen.org.nz> To: Eric Boucher <eric_boucher60@yahoo.com> Cc: FreeBSD <freebsd-questions@FreeBSD.ORG> Subject: Re: Bourne shell programming problem Message-ID: <20020220201026.A53598@grimoire.chen.org.nz> 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>
index | next in thread | previous in thread | raw e-mail
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 <jonc@chen.org.nz>
----------------------------------------------------------------------
"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
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020220201026.A53598>
