0

While I working on a script I need to print available SSID only.
I tried this:

sudo iwlist wlp2s0 scan | grep ESSID

I got output like this:

ESSID:"CoreFragment_5G"
                    ESSID:"dlink"
                    ESSID:"REDWING LABS"
                    ESSID:"Hitachi"
                    ESSID:"COMFAST"
                    ESSID:"Yash Shah"
                    ESSID:"CoreFragment"
                    ESSID:"Appbirds_Technologies"
                    ESSID:"20096641"
                    ESSID:"REDWING LABS_5G"

But I want to print name only. How to filter this command?

2 Answers 2

1

There are many ways to do it, using awk:

sudo iwlist wlp2s0 scan | grep ESSID | awk -F '"' '{print $2}'

Or using cut:

sudo iwlist wlp2s0 scan | grep ESSID | cut -d '"' -f2

These commands will give you the names without ".

1
  • Thank you for your responce . it works...
    – Yash Shah
    Jan 3, 2019 at 6:47
0
sudo iwlist wlp2s0 scan | grep ESSID | sort |uniq | awk -F: '{print $2}' 

Will give you the list of available ssid in quotes, to get rid of quotes use tr -d \", i.e,

sudo iwlist wlp2s0 scan | grep ESSID | sort |uniq | awk -F: '{print $2}' | tr -d \"

Here the sort and uniq only prints the unique ssid, and awk grabs only the names.

0

You must log in to answer this question.

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