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

Posted

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 one liner that just does that one thing and nothing else.

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