Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[[ b == [A-B] ]]; echo $? # returns 0 in bash. why?

6 views
Skip to first unread message

Name withheld by request

unread,
Sep 11, 2011, 10:38:45 AM9/11/11
to
pls explain:

$ [[ b == [A-B] ]]; echo $?
0
$ [[ b == [B] ]]; echo $?
1
$ [[ b == [b] ]]; echo $?
0
$ echo $BASH_VERSION
4.1.10(4)-release

--
thanks

Christian Barthel

unread,
Feb 5, 2012, 4:45:44 AM2/5/12
to
If you want to compare a string:

STRING1 = STRING2
the strings are equal

If you want to compare a number:

INTEGER1 -eq INTEGER2
INTEGER1 is equal to INTEGER2

See also:
man test
>
> --
> thanks

Janis Papanagnou

unread,
Feb 5, 2012, 7:26:29 AM2/5/12
to
You are answering to a very old posting, and apparently haven't read
the replies given at that time; you completely missed the OP's point.

Janis

BTW, man test may be misleading if using the [[...]] shell built-in.

>>
>> --
>> thanks

Kenny McCormack

unread,
Feb 5, 2012, 7:47:27 AM2/5/12
to
In article <jglshl$2c3$1...@news.m-online.net>,
Janis Papanagnou <janis_pa...@hotmail.com> wrote:
...
>You are answering to a very old posting, and apparently haven't read
>the replies given at that time; you completely missed the OP's point.

Yes, but completely missing OPs' point(s) is the whole point of Usenet.

--
"We should always be disposed to believe that which appears to us to be
white is really black, if the hierarchy of the church so decides."

- Saint Ignatius Loyola (1491-1556) Founder of the Jesuit Order -

Eric_DL

unread,
Feb 5, 2012, 10:19:17 AM2/5/12
to
Name withheld by request <anon...@nyx3.nyx.net> wrote:

Hi,

It may be because of your curent locale setting (command line is "locale").
If your locale sort alphanumeric characters this way : a,A,b,B,c,C,...
then b is actually in the interval [A-B].
Check section "Pattern Matching" in :
http://www.linuxcommand.org/man_pages/bash1.html to see the influence of
the LC_COLLATE shell variable.

Cheers
Eric


--
PM : http://www.webuse.net/pm.php?u=2832

Posted using www.webuse.net
0 new messages