我想计算作为命令输出获得的以字符串“ tun ”开头的条目数ifconfig
。
例如,如果这是我的输出,我想计数为 2。我尝试玩弄grep
,但仍然没有解决。
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.0.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:16:73:86:ba txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s31f6: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:00:00:00:00:00 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns …
Run Code Online (Sandbox Code Playgroud)