You can achieve this using awk as shown on this site. I've posted an excerpt here which produces your desired result:
ifconfig | awk '/dr:/{gsub(/.*:/,"",$2);print$2}'
You can do
ifconfig -a|grep inet| awk -F' ' '{print $2}'