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

Trackback URI | Comments RSS

Leave a Reply

Name (required)

Email (required)

Website

Speak your mind

    Stuff
    Everyone
    Calendar
    November 2009
    M T W T F S S
    « Oct   Dec »
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30  
    Rate this blog
    Clickity
    15429
Get Adobe Flash playerPlugin by wpburn.com wordpress themes