I want to edit the bashrc file to have a simple function called \"myip\" to run. As you might guess, the function myip prints only my internal IP address of my machine.
After trying some solutions i find this most handy, add this to your alias:
alias iconfig='ifconfig | awk '\''{if ( $1 >= "en" && $2 >= "flags" && $3 == "mtu") {print $1}; if ( $1 == "inet" || $1 == "status:"){print $0};}'\''|egrep "en|lo|inet"'
the output looks like this:
shady@Shadys-MacBook-Pro:xxxx/xxx ‹dev*›$ iconfig
lo0:
inet 127.0.0.1 netmask 0xff000000
en0:
inet 10.16.27.115 netmask 0xffffff00 broadcast 10.16.27.255
en1:
en2:
en5:
inet 192.168.2.196 netmask 0xffffff00 broadcast 192.168.2.255