Linux命令管道:使用带有grep的iwlist来显示两条信息

时间:2016-09-21 10:27:10

标签: linux grep

我用

sudo iwlist [My Wifi interface] scan 

获取我周围的访问点的所有信息的列表,例如结果如下

Cell 39 - Address: AA:AA:AA:AA:AA:AA
                Channel:11
                Frequency:2.462 GHz (Channel 11)
                Quality=39/70  Signal level=-71 dBm  
                Encryption key:on
                ESSID:""
                Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
                          36 Mb/s; 48 Mb/s; 54 Mb/s
                Mode:Master
                Extra:tsf=000000312d7ef1a6
                Extra: Last beacon: 520ms ago
                IE: Unknown: 0000
                IE: Unknown: 01088C929824B048606C
                IE: Unknown: 03010B
                IE: Unknown: 050400010000
                IE: Unknown: 2A0100
                IE: IEEE 802.11i/WPA2 Version 1
                    Group Cipher : CCMP
                    Pairwise Ciphers (1) : CCMP
                    Authentication Suites (1) : PSK
                IE: Unknown: 2D1AAD1917FFFF000000000000000000000000000000000000000000
                IE: Unknown: 3D160B080400000000000000000000000000000000000000
                IE: Unknown: 4A0E14000A002C01C800140005001900
                IE: Unknown: 7F080500080000000040
                IE: Unknown: DD07000B8601040812
                IE: Unknown: DD180050F2020101800003A4000027A4000042435E0062322F00

另外,我可以使用

sudo iwlist wlp2s0 scan | grep ESSID

仅获取ESSID,例如结果如下

ESSID:"wifi1"
ESSID:"wifi2"
ESSID:"wifi3"

我的问题是: 如何使用grep或任何其他命令来显示" ESSID"和"信号等级"?

1 个答案:

答案 0 :(得分:2)

您可以修改正则表达式以捕获多个单词,如下所示:

sudo iwlist wlp2s0 scan | grep 'ESSID\|Signal level'

请参阅grep online的文档或终端中的man grep