From: awt13a on
Hello,
first of all I'm a novice in shell programming !
Can someone tell me how to modify a local string variable ?

example:

set MYNEWVAR=$HOSTNAME
echo $MYNEWVAR deliveres e.g. unx123456.de.hh.lincroft.de

How can I get only the first part of the string (unx123456) written
into MYNEWVAR ?

Mike

From: Ben on
awt13a(a)yahoo.de wrote:
> echo $MYNEWVAR deliveres e.g. unx123456.de.hh.lincroft.de
>
> How can I get only the first part of the string (unx123456) written
> into MYNEWVAR

untested

set MYNEWVAR = `hostname | awk -F\. '{print $1}'`
From: Keith Thompson on
Ben <none(a)none.com> writes:
> awt13a(a)yahoo.de wrote:
>> echo $MYNEWVAR deliveres e.g. unx123456.de.hh.lincroft.de
>> How can I get only the first part of the string (unx123456) written
>> into MYNEWVAR
>
> untested
>
> set MYNEWVAR = `hostname | awk -F\. '{print $1}'`

It's not clear from the original article that $HOSTNAME came from the
output of the "hostname" command.

This should work:

set MYNEWVAR = `echo $HOSTNAME | sed 's/\..*$//'`

(I find the use of sed simpler, and therefore better, than the use of
awk in this context.)

--
Keith Thompson (The_Other_Keith) kst-u(a)mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.