On Sat, 29 Dec 2001, Anthony E. Greene wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On Fri, 28 Dec 2001, Patrick Nelson wrote:
> >For some reason I just cant get this...
> >
> >me@mehost>setap -l | grep ESSID:   # lists the following
> >lo        no wireless extensions.
> >
> >eth0      IEEE 802.11-DS  ESSID:"MECOOLAP01"  Nickname:"mehost"
> >me@mehost>
> >
> >I'm trying to figure out how to pull the MECOOLAP01 from the line.  Any
> >suggestions?
> 
> setap -l | grep ESSID: | cut -f 2 -d ':' | cut -f 1 -d ' ' | sed -e
> "s/\"//g"
> 
> 
> That is all one line.

$ line=$(setap -l | grep ESSID)
$ essid=$(expr "$line" : ".*ESSID:\"\([^ ]*\)\"")
$ echo $essid

  why this works is left as an exercise for the reader, but it
demonstrates the pattern-matching and extraction power of the
woefully-overlooked "expr" command.  note the efficiency as well,
and how, if you wanted, you could combine it all into one line.

rday



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to