Sometimes you might need your machines IP adress in a script. There are solutions to this using external sources, but that wont always work 😉 So heres how to get your IP from your computers data.. (Using grep)
You sometimes need your machines IP adress without relying on external sources; so here is the command to return your IP adress in one neat line.ifconfig eth0 | grep -o "addr:[0-9.]*" | grep -o "[0-9.]*"
You off course need the necessary rights to us this. If you lack the rights, you might want to prepend it with “sudo” and add the ifconfig to the allowed paswordless commands for the user that needs this..
Ifconfig retrieves the adress; the first grep weeds out the external adress out of the data & the last grep filters out the IP adress.
I posted this to shell-fu and will link it here should it be published..
Edit: Shell-Fu published it today – hooray for being usefull 🙂 Shell-Fu: 554