I-Am-Bot Code, technology and life

30Nov/090

MAC/IP address using Linux shell script

Ever wanted to get the MAC/IP address of your computer in a Linux shell script? The following two commands should work on most flavours of Linux/Unix

Note: It retrieves the address of eth0 interface by default. Make necessary changes as required.

IP:

/sbin/ifconfig | grep '\<inet\>' | sed -n '1p' | tr -s " " | cut -d " " -f3 | cut -d ":" -f2

MAC (H/W address)

/sbin/ifconfig | grep 'eth0' | tr -s " " | cut -d " " -f5

Posted by Srinath

Tagged as: , Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.