用sed从ifconfig取IP和mac地址

| 3 Comments | No TrackBacks
作弊条一个,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里执行。

No TrackBacks

TrackBack URL: http://mt.khsing.net/cgi-bin/mt-tb.cgi/47

3 Comments

中午jackos说这里有个问题就是应该把ifconfig和sed写成全路径,应该如此。
嘿嘿,我先沙发一下
似乎在中文系统中不起作用

Leave a comment

About this Entry

This page contains a single entry by Guixing published on January 7, 2009 3:28 PM.

2008别了 was the previous entry in this blog.

route flags in FreeBSD and Linux is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.