Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Thank you | 20 comments | Create New Account
Click here to return to the 'Thank you' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Thank you
Authored by: kps on Oct 19, '05 05:47:42PM
I get so sick of people using awk for things that sed should be doing :-)
ifconfig | sed -n -e '/' -e 's/.*inet \(.*\) netmask.*/\1/p'
(I also get sick of macosxhints eating backslashes.)

[ Reply to This | # ]
Thank you
Authored by: Whosawhatsis on Oct 20, '05 05:06:03PM
To get the same output using awk:
ifconfig | awk '$1 ~ /^inet$/ && $2 !~ /^$/ {print $2}'
Shorter, and no backslashes to be stripped out :P

I was offered a penny for my thoughts, so I gave my two cents... I got ripped off.

[ Reply to This | # ]