![iproute2 获取 inet 接口](https://linux22.com/image/108598/iproute2%20%E8%8E%B7%E5%8F%96%20inet%20%E6%8E%A5%E5%8F%A3.png)
我尝试过的事情:
scope inet
给出Error: argument "inet" is wrong: invalid "scope"
to inet
给出Error: ??? prefix is expected rather than "inet".
- (标志)
inet
给出Error: either "dev" is duplicate, or "inet" is a garbage.
label inet
没有输出- 项目清单
这已经耗尽了我的想法。是否有一种内置方法可以无需令人讨厌的 grep 即可获取接口属性
答案1
$ ip -f inet addr show wlan0 | grep -Po 'inet \K[\d.]+'
192.168.1.20