8

I tried $iwconfig | grep wlan0 but all I got was the line that my connected ESSID name exists. But I need only the name.

How do I get just the name?

2 Answers 2

7

I don't know if this is the best solution, but try this:

For the essid name:

iwconfig wlan0 2> /dev/null | awk -F\" '{print $2}'

For the access point mode (as requested in the comment):

iwconfig wlan0 2> /dev/null | awk -F: '/Mode:/ {print $2}' | awk '{print $1}'

For the link Quality (as requested in the comment):

iwconfig wlan0 2> /dev/null | awk -F= '/Quality/ {print $2}' | awk '{print $1}'

For the channel, (as requested in the comment) try this:

sudo iwlist wlan0 scanning essid ESSID | grep Channel | head -1 | awk -F: '{print $2}'

Make sure to replace ESSID with your essid:

For the address, (as requested in the comment) try this:

ifconfig wlan0 2> /dev/null | awk -F: '/inet\ addr/ {print $2}' | awk '{print $1}'
7
  • That's perfect.
    – Ibrahim
    Nov 4, 2012 at 19:20
  • Can you help me to find another informations. (channel connection,mode of my Access Point,Quality,
    – Ibrahim
    Nov 4, 2012 at 19:36
  • yeah, sure, ill add them to the answer above, i'm about to leave now, but ill add them later on
    – Sam
    Nov 4, 2012 at 19:50
  • all worked except the channel's coomand
    – Ibrahim
    Nov 4, 2012 at 20:27
  • My bad, make sure to replace "ESSID" with your own essid!
    – Sam
    Nov 5, 2012 at 2:03
3

After toying around with tons of different commands, flags, greps, trims, awks, and seds, I finally settled on:

iwgetid -r

Simple and clean. This will output the SSID and nothing more. Previously, I was using this clunker:

iwconfig <iface> | grep ESSID | awk -F: '{print $2}' | sed 's/\"//g'

One of my favorite things about the *nix world is the ability to string together a bunch of commands and programs that utilize standard input and output to achieve whatever it is that I need. However, when a single flag can be passed to a program like iwgetid to accomplish the same thing, it's no longer a decision between which to use. It's an IQ test.

Keep in mind you can still specify different wireless network interfaces using iwgetid like so:

iwgetid <iface> -r

You must log in to answer this question.

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