Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Display current network location via the Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Display current network location via the Terminal
Authored by: Ferdy on Sep 23, '04 12:24:30PM
scselect 2>&1 | grep '^ \*' | sed -e 's:^[^(]*(\([^)]*\))$:\1:g'
I think this is much better.
Thanks.

[ Reply to This | # ]
Display current network location via the Terminal
Authored by: ua on Sep 23, '04 03:43:38PM
Shorter:
scselect | perl -lne 'print $1 if /^ \*.*\((.*)\)/'
Probably prints an error message if scselect fails. Probably prints nothing if no location is selected.

[ Reply to This | # ]
Display current network location via the Terminal
Authored by: Ferdy on Sep 24, '04 08:23:36AM
Hehe... i tried not to use perl because i don't relly know it. But it does not handle nested (. Anyway i modified a bit on mines and now it does:
sed 's:^[^(]*(\(.*\))$:\1:g'
though i dont like perl, yours is shorter :D Cheers,Ferdy

[ Reply to This | # ]
Display current network location via the Terminal
Authored by: VF on Dec 16, '04 01:31:36AM
Here is another way to do it (might be more human-readable...).

#!/bin/sh
scselect 2>&1 | grep '^[ ]*\*' | cut -d'(' -f2 | cut -d')' -f1
P.s.: Of course, also preserves SPACEs in your location-name.

---
VF

[ Reply to This | # ]