[root@test ~]# ifconfig | grep "inet addr:" | grep [^127]
inet addr:172.21.1.222 Bcast:172.21.1.255 Mask:255.255.255.0
inet addr:127.0.0.1 Mask:255.0.0.0
ifconfig | grep "inet" | grep "127"
ifconfig | grep "inet addr:" | grep "127"
好无聊
# ifconfig | grep "inet\ addr:\ [1,2][^2][^7]"
# ifconfig | grep "inet\ addr:\ 1[^2]"
第一 空格需要 “\” 转义符 grep "inet\ addr:"
第二 “[^127]” 表示 不是1或2或7的数字,写法错误。 应该写 "[^1][^2][^7]"