Hi all:
say,there is such a awk statment in a "test.sh" file:
hostname_1=`hostname`
IP=`cat /etc/hosts | awk '{ if ($2==hostname_1) print $1}'`
echo $IP
the IP of hostname_1 in /etc/hosts is 165.167.189.21
but WHY IT OUTPUTS a blank line?????
WHY IP cannot get the corresponding value in the /etc/hosts???
Thanks!!!
This is in very urgent need!!
say,there is such a awk statment in a "test.sh" file:
hostname_1=`hostname`
IP=`cat /etc/hosts | awk '{ if ($2==hostname_1) print $1}'`
echo $IP
the IP of hostname_1 in /etc/hosts is 165.167.189.21
but WHY IT OUTPUTS a blank line?????
WHY IP cannot get the corresponding value in the /etc/hosts???
Thanks!!!
This is in very urgent need!!