ifconfig与etho获取ip的问题

1:怎么获取本地IP的值?
2:ifconfig和etho的用法
3:这句话的解释OUT_IP="$(ifconfig | grep -A 1 'eth0' | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1)"

ifconfig 查看本地ip
ifconfig | grep -A 1 'eth0' 从本地ip信息里查看到eth0 的前两行信息
ifconfig | grep -A 1 'eth0' | tail -1 取第二行信息
ifconfig | grep -A 1 'eth0' | tail -1 | cut -d ':' -f 2 第二行信息基础上以冒号分段,取第2个字段
ifconfig | grep -A 1 'eth0' | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1 在取第2个字段基础上以空格分段,取空格分段后的第1个字段
可以改一下最后那个的值,可能有的机器不是1,我试了一下我的是10

echo就是直接显示信息。