ifconfig eth0 | sed -n '/^[A-Za-z0-9]/ {N;/dr:/{;s/.*dr://;s/ .*//;p;}}'
So you want to display just your IP address and not all the other stuff that comes with using the ifconfig command. Then use the above command.
It’s useful if you need your IP address in a script but you don’t want to set a static address for your machine, it outputs just the IP address on a single line as shown below:
Hello,
you have write ‘ but it’s ‘ :)
Thanks
Morphau
I have no idea what you’re referring to, sorry.
@Alex, Morphau was referring to the fact that your snippet doesn’t run if you copy/paste it into a terminal.
It has apparently been mangled by a “smart” (!) text editor. The regex argument to sed is enclosed in a matching pair of quote characters. They should both be the ordinary kind of apostrophe character: ‘
Ah yes, I see. I’ve had this trouble with wordpress before, I’ll try and fix it.