1

From :

sudo iwlist wlan0 scan | grep Frequency

I get

                Frequency:2.412 GHz (Channel 1)
                Frequency:2.412 GHz (Channel 1)
                Frequency:2.462 GHz (Channel 11)

But I want only output as

1
1
11
1
  • 1
    I'd strongly suggest taking a look at some regular expression tutorial first. You can then get what you want using grep -o, sed, or awk.
    – TooTea
    Jan 10, 2019 at 11:00

1 Answer 1

2

Add |awk -F 'Channel' '{print $2}' |cut -d ')' -f 1 to the command as this:

sudo iwlist wlan0 scan | grep Frequency |awk -F 'Channel' '{print $2}' |cut -d ')' -f 1

awk filter the world "Channel" while with the put you avoid the last ).

1
  • sudo iwlist wlan0 scan | sed -r -e 's/Frequency.*\(Channel ([0-9]+)\)$/\1/' Jan 10, 2019 at 11:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .