首页 > 代码库 > awk查看本机IP+查看本网段mac

awk查看本机IP+查看本网段mac

ifconfig | awk ‘/inet addr/‘  | awk ‘!/127.0.0.1/‘ |awk -F ‘:‘ ‘{print $2}‘ |awk ‘{print $1}‘  (#centos6)
ifconfig | awk ‘/inet/‘|awk ‘!/inet6|127.0.0.1/‘|awk ‘{print $2}‘  (#centos7.3)

  

  

 

echo -e `for i in {1..254}; do  ping -W1 -c1 192.168.77.$i ;done` > /dev/null  &&    arp -n | awk ‘/:/‘ | sort -t. -k4 -n
(#循环{a..b}需求bash 4.0+)

 

  

 

awk查看本机IP+查看本网段mac