Quote:
> who am i
ops pts/69 Sep 18 11:14 (spfea29)
In this command I get:
> export IP_ADDR=`who am i|cut -d\(-f2|cut -d\) -f1`
> echo $IP_ADDR
spfea29
who am i returns the string you see
cut using a delimiter of (
note the \ before the ( to tell unix that the character should not be interpreted
the -f2 says to take the 2nd field; what is after the (
then using a delimiter of )
again utilizing the \ so as not to interpret the )
this time saying take field 1; everything before the )
Here is another way of doing it
IPX=`who am i | cut -d"(" -f2 | cut -d")" -f1`
or
IPX=$(who am i | cut -d"(" -f2 | cut -d")" -f1)