shell获取本机网卡ip脚本

前端之家收集整理的这篇文章主要介绍了shell获取本机网卡ip脚本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

vi ip.sh

#!/bin/bash
ifconfig $1|sed -n 2p|awk '{ print $2 }'|awk -F : '{ print $2 }'

##ifconfig $1|sed -n 2p|awk '{ print $2 }'|tr -d 'addr:'#这个也可以实现####

执行:

./ip.sh eth0
192.168.2.4


猜你在找的Shell相关文章