Waleed Mohammad Waleed Mohammad - 1 month ago 4x
Linux Question

Linux commands pipe: using iwlist with grep to display two piece of information

I use

sudo iwlist [My Wifi interface] scan

to get a list of all the information of access points around me e.g. the result below

Cell 39 - Address: AA:AA:AA:AA:AA:AA
Frequency:2.462 GHz (Channel 11)
Quality=39/70 Signal level=-71 dBm
Encryption key:on
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
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

Also, I can use

sudo iwlist wlp2s0 scan | grep ESSID

to get the ESSID only e.g. the result below


My question is:
How can I use grep, or any other command for that matter, to get to display both "ESSID" and "Signal level"?


You can modify the regular expression to just catch multiple words, like this:

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

See the documentation of grep online or using man grep in your terminal.