Unix questions - Difference between ${B*} and ${!B*}

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > January 2007 > Difference between ${B*} and ${!B*}





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Difference between ${B*} and ${!B*}
George

2007-01-14, 7:20 am

Dear All,

Could somebody please explain the difference between these two? Are they
not both supposed to echo variables starting with B?

Thanks,
George
Stephane CHAZELAS

2007-01-14, 7:20 am

2007-01-14, 11:07(+00), George:
> Dear All,
>
> Could somebody please explain the difference between these two? Are they
> not both supposed to echo variables starting with B?

[...]

Not in a Unix conformant shell anyway. See the manual of your
shell to see if it supports it as an extension.

--
Stéphane
Conrad J. Sabatier

2007-01-17, 7:28 pm

In article Pine.GSO.4.58.0701141106300.21632@vega.soi.city.ac.uk, dated
Sun, 14 Jan 2007 11:07:33 +0000, George <me@me.com> wrote:

> Dear All,
>
> Could somebody please explain the difference between these two? Are they
> not both supposed to echo variables starting with B?


Not in any shell I'm aware of.

What shell are you using, and where did you get the notion that this
notation was supported by it?

You could try something like this instead (for Bourne and compatible
shells such as bash, etc.):

set | grep ^B

or possibly:

env | grep ^B

HTH

--
Conrad J. Sabatier <conrads@cox.net>
"In Unix veritas"
Stephane CHAZELAS

2007-01-18, 7:28 am

2007-01-18, 00:57(+00), Conrad J. Sabatier:
> In article Pine.GSO.4.58.0701141106300.21632@vega.soi.city.ac.uk, dated
> Sun, 14 Jan 2007 11:07:33 +0000, George <me@me.com> wrote:
>
>
> Not in any shell I'm aware of.

[...]

printf '%s\n' "${!B*}"

outputs a space separated list of variable names starting with B
with both bash and ksh93.

printf '%s\n' "${!B@}"

outputs the list of variables in distinct arguments. Useful when
environment variable names contain space or newline characters:

$ env 'Z1 a=' 'Z2
b=' bash -c 'printf "<%s>\n" "${!Z@}"'
<Z1 a>
<Z2
b>


--
Stéphane
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com