Anyway, here's something which I hope will be useful.
I find it awkward to pick out my Mac's IP addresses at a glance from the output of "ifconfig -a". Here's a command-line that makes it very easy...
[eamonn@stig ~]$ ifconfig -a | perl -ne '$interface=$1 if (/^([a-z]+[0-9]+:)/); print "$interface $1\n" if (/inet (\d+\.\d+\.\d+\.\d+)/);'
lo0: 127.0.0.1
en0: 192.168.78.112
Now even the most commited command-line disciple is likely to baulk at typing all that, so I have an alias set up in ~/.bash_login. The quotes are a little fiddly to get right, so here's the alias...
alias ipa='ifconfig -a | perl -ne '\''$interface=$1 if (/^([a-z]+[0-9]+:)/); print "$interface $1\n" if (/inet (\d+\.\d+\.\d+\.\d+)/);'\'
A slight variation of the same thing works on Linux also (with adjustments to compensate for the differences in output format)...
alias ipa='ifconfig -a | perl -ne '\''$interface=$1 if (/^([a-z]+[0-9]+) /); print "$interface $1\n" if (/inet addr:(\d+\.\d+\.\d+\.\d+)/);'\'
I hope its useful...
No comments:
Post a Comment