Have you tried awk?
$> iwlist wlan0 scan | egrep 'Address|ESSID' | awk -F : '{ $1="";print}'
00 24 7E 1F 7B 4D
"YouShallNotPass!"
With -F I changed the separator to colon :
and alas took other colons from address, which can be remedied with setting OFS, like below:
$ iwlist wlan0 scan | grep Add | awk -F : '{OFS=":";$1="";print substr($0, 3) }'
00:24:7E:1F:7B:4D
Looking at the results of 'iwlist ... scan' itself, they aren't always regular. I should mention two other lines you won't get this way:
- Quality and Signal (no colon), use instead
iwlist wlan0 scan | grep Quality | awk '{print $3}' | awk -F = '{print $2}'
for Signal
iwlist wlan0 scan | grep Quality | awk '{print $1}' | awk -F = '{print $2}'
for Quality
- Bit rates (well, in my case there are three lines with Bit rates, and one has no colon, just values - obviously the Awk script above misses it).
I'm not so familiar with what bit rates display exactly so not knowing your use case for this and whether this differs between many WiFi drivers/cards/others I lack info to help here.
Mind you - there are other options, but you withheld what you need and what for, so I gave you simple (if long) Awk-specific solution. Same info can be obtained via Perl regex or even Bash.
iwlist wlan0 scan|egrep 'Address|ESSID' | cut -d ":" -f 2-
try this