我正在寻找如何使用egrep
或grep
完成我的任务。
我想显示每个接口的最后一行。我尝试使用grep
and egrep
with 选项,但结果并没有达到我的预期。
#ifconfig -a
en0: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN>
inet 10.x.x.x netmask 0xffffff80 broadcast 10.x.x.x
tcp_sendspace 16384 tcp_recvspace 16384 rfc1323 0
en1: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN>
inet 10.x.x.x netmask 0xfffffff0 broadcast 10.x.x.x
tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
en2: flags=1e080863,480<UP,BROADCAST,10.x.x.xmask 0xffffff80 broadcast 10.x.x.x
tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN>
inet 127.0.0.1 netmask 0xff000000 broadcast 10.x.x.x
inet6 ::1%1/0
tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1
预期输出:
en0: tcp_sendspace 16384 tcp_recvspace 16384 rfc1323 0
en1: tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
en2: tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
lo0: tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1