ubuntu下仅仅获取网卡一的ip地址 && shell中字符串拼接

问题描述:

  ubuntu下仅仅获取网卡一的ip地址

问题背景:

  eth0,eth1,eth2……代表网卡一,网卡二,网卡三……

  lo代表127.0.0.1,即localhost

sudo ifconfig eth0 | grep 'inet addr' | cut -d : -f 2 | cut -d ' ' -f 1

问题描述:

  已知字符串str1, str2, 拼接str1和str2,结果为str3

  

str1=hello
str2=world
str3="$str1 $str2"
echo $str3