Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jul 2002 13:38:48 -0700 (PDT)
From:      Viktor Lazlo <viktorlazlo@telus.net>
To:        Odhiambo Washington <wash@wananchi.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Shell Script gurus??
Message-ID:  <20020704132754.E21920-100000@njam.dhs.org>
In-Reply-To: <20020704172903.GF56027@ns2.wananchi.com>

next in thread | previous in thread | raw e-mail | index | archive | help


On Thu, 4 Jul 2002, Odhiambo Washington wrote:

> Now in my script I am reading the domain name from stdin (??
>
> 	echo Entering domain name in MySQL DB:
>         echo ""
>         domain_name=
>         echo -n Please supply the domain name to activate:
>         read domain_name
>
>
> The domain name can be domain.com or the domain.co.ke but I am interested
> in the part before the first (.) so that I can manipulate some parameter
> with it.
>
> How do I get that alone in a shell after I've read the domain name into
> a variable??

I'm sure there's much slicker ways of going about doing it but this works
for me:

read var1
var2=`echo $var1 | sed -n 's/\.com//p'`

Regards,

Viktor


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?20020704132754.E21920-100000>