One command to rule…. alright, just return an IP

One of my friends who is into networks always joke, as why there is no single Unix command to return only the IP address and nothing else. Here is a script that just does that one thing and nothing else.

#!/usr/bin/env bash # Arvinder Singh Kang # askang@olemiss.edu # Version 0.1 - 2009-06-02 # ipaddress: This snippet returns the ipaddress of the current computer. Store in a directory which is in the PATH, and make it executable by running "chmod +x ipaddress". # Running command ipaddress should return ipaddresses of this machine.

ifconfig  | grep -E 'inet.[0-9]' | grep -v '127.0.0.1' | awk '{ print $2}'

This entry was posted in Hacks and tagged , , . Bookmark the permalink.

2 Responses to One command to rule…. alright, just return an IP

  1. Hello Kang Paaji,

    Looks like something is missing…i mean…i think….it should be IPCONFIG, in place of IFCONFIG… I am not sure….

    Regards Baljit

  2. Baljit,

    The equivalent command for Windows’ ipconfig command in Unix/Linux is ifconfig

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>