809areacode |
08-17-2011 11:24 AM |
My sed/gawk script works, but is complicated. How would you do this?
I'm using /sbin/ifconfig and piping it into sed and gawk to retrieve just my system's IP address. I placed the script in a file called 'ifi', which I run whenever I need an IP address in another script. It works fine.
Code:
$ echo `ifconfig | grep "inet addr:" |gawk -F: '{print $2}'` |sed '2p'|gawk '{print $3}'
192.168.x.x
$
Like I said, it works fine. Now I use it for logging...
Just... it's kind of complicated, don't you think? Just let me know how you would do it. :)
|