By default ifconfig will show me all available interfaces , but what if I just want to display active ones? Like, en0 only in below. en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500    ether 14:10:9f:e0:eb:c9     inet6 fe80::1610:9fff:fee0:ebc9%en0 prefixlen 64 scopeid 0x4     inet X.X.X.X netmask 0xffffff00 broadcast 101.6.69.255    nd6 options=1<PERFORMNUD>    media: autoselect    **status: active**en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500    options=60<TSO4,TSO6>    ether 32:00:14:e7:4f:80     media: autoselect <full-duplex>    **status: inactive**Notice ifconfig en0 will not satisfy, en0 is not always the active one ;)I'm running Mac OS X.
How to use ifconfig to show active interface only
command line;networking;osx;interface
To get a complete description of all the active services, try:ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'This simple regex should filter out only active interfaces and all their information.  I sugest you put an alias for this in your ~/.profile or ~/.bash_profile file (maybe ifconfiga?)To just get the interface name (useful for scripts), use:ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active' | egrep -o -m 1 '^[^\t:]+'You have to install pcregrep for this to work.  It's on macports in the pcre package.  Alternatively, this should work with GNU grep using grep -Pzo instead of pcregrep -M -o but with the rest the same, but I haven't tested this.  