用sed从ifconfig取IP和mac地址

作弊条一个,Linux下

ifconfig | sed -e '/.*inet addr:/!d;s///;s/ .*//'
ifconfig | sed -e '/.*HWaddr \([:[:xdigit:]\-]*\).*/{s//\1/;p}'

FreeBSD下

ifconfig | sed -e '/.*inet /!d;s///;s/ .*//'
ifconfig | sed -e '/.*ether/!d;s///;'

都要在sh或bash里执行。

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.