At 2004-06-21T105056+1200, Jim Cheetham wrote:
> Man, that takes all the fun out of bash and pipelines ... :-)
Ah, yeah, I forgot to mention that it's bash specific.
You can do the same thing in bash, ksh, and dash with:
$ echo ${SSH_CLIENT%% *}
(in fact, that may work with all POSIX shells, but I haven't checked)
> But it looks like a nice bash parameter expansion - I don't recognise
> it. Where in the man page is it explained? It seems to be a general
> regexp substitution, which would be faster than a call to sed within a
> pipeline ...
EXPANSION section, Parameter Expansion subsection.
It's not a regexp, though, it's the shell's pattern matching goo.
At 2004-06-21T110818+1200, Nick Rout wrote:
> unless of course you have ipv6 enabled:
> [EMAIL PROTECTED] nick $ echo ${SSH_CLIENT/ */}
> ::ffff:203.79.82.53
> now probably not many people do, but it may also be worth taking into
> account or a script may suddenly break.
Good catch. Something like the following should handle that.
$ BLAH=${SSH_CLIENT%% *}
$ echo ${BLAH##*:}
Cheers,
-mjg
--
Matthew Gregan |/
/| [EMAIL PROTECTED]