Date: Fri, 05 Jul 2002 09:35:25 -0500 From: C Peter Biessener <pbiessener@hirshfields.com> To: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: Shell Script gurus?? Message-ID: <3D25AEAD.2040103@hirshfields.com> References: <20020704140403.L333-100000@atlas.home>
index | next in thread | previous in thread | raw e-mail
The pattern matching which Mikko suggested will work, but is not
guaranteed to be available in all shells.
Two other methods are:
host=`echo $domain_name | cut -f1 -d`
-OR-
host=`echo $domain_name | awk -F"." '{print $1}'`
M.T. wrote:
> On Thu, 4 Jul 2002, Viktor Lazlo wrote:
>
>
>>
>>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:
>
>
> You mean something like:
>
> domain_name="${domain_name%%.*}"
>
> :-)
> /Mikko
>
>
>>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
>>
>
>
>
> 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
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D25AEAD.2040103>
