本帖最后由 sky_mld 于 2024-1-26 20:57 编辑
使用awk命令:
- [ssl@ssl-PC ~]$ ifconfig enaftgm1i1
- enaftgm1i1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.254
- inet6 fe80::38a:9d43:288c:2eac prefixlen 64 scopeid 0x20<link>
- ether 98:0e:24:02:c4:8f txqueuelen 1000 (Ethernet)
- RX packets 350960717 bytes 21187532229 (19.7 GiB)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 732590 bytes 66395741 (63.3 MiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- device interrupt 10
- [ssl@ssl-PC ~]$ ifconfig enaftgm1i1 | awk 'NR==2{print $2}'
- 192.168.1.1
复制代码- ifconfig enaftgm1i1 | awk 'BEGIN{RS=""}{print $6}'
复制代码
使用sed命令- [ssl@ssl-PC ~]$ ifconfig enaftgm1i1 | sed -nr 's/.*inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/p'
- 192.168.1.1
复制代码
|
|
|
|
|
版权说明:论坛帖子主题均由合作第三方提供并上传,若内容存在侵权,请进行举报