ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I never realized before that /usr/bin/test existed. But test is also a bash builtin. It is described in bash's man page under SHELL BUILTIN COMMANDS. The description for test describes how to combine "primaries" and further advises the reader:
Quote:
Expressions are composed of the primaries described above under CONDITIONAL EXPRESSIONS.
So in the bash man page you would need to look under CONDITIONAL EXPRESSIONS for the information you seek. Admittedly, there is so much information in the bash man page that it can be a real pain to navigate.
EDIT: I probably should have mentioned that bigearsbilly's answer to what -r means in this case is still correct.
Last edited by blackhole54; 08-14-2009 at 06:23 PM.
Actually, bash uses its own built-in test (try "type test" or "type ["). But the operation of it is almost exactly the same as the external tool, so the man page still works as a reference.
Thanks guys for all your replays... I did read in abs that ____[dont remember what now.] was synonymous of "test" but I didnt realize that it was EVERYTHING between []...
I'm glad you brought that up because it has been an unresolved uncertainty for me for a long time; unresolved because IIRC [[ ]] has advantages over [ ] leaving no reason to use [ ] and hence no reason to understand it. The pragmatism of a young man in a hurry!
The closing ] is necessary, though. According to the Gnu bash Reference for test, "When the [ form is used, the last argument to the command must be a ]". That's kludgy!
... unresolved because IIRC [[ ]] has advantages over [ ] leaving no reason to use [ ] and hence no reason to understand it.
I am not sure if there is anything [...] can do that [[...]] cannot or not (a lot of nuances that would need to be checked out). If you have something that works for you, fine. But people who read this thread, particularly those that are just starting out, should realize that [[...]] is not a drop-in replacement for [...]. Of the top of my head, the == operator is interpreted differently and the 'logical and" and "logical or" operators are expressed differently. There may be other differences.
Last edited by blackhole54; 08-15-2009 at 06:09 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.