Markus, On Friday 01 April 2005 05:17, Markus Gaugusch wrote:
On Apr 1, pelibali <pelibali@freemail.hu> wrote:
Hi,
...
By the way I have an interesting '/usr/bin/[' file as well; is this strange name just an accident or it supposed to be like this? And why then this uncommon name?
This is the short name for the "test" command, used like if [ -f /etc/passwd ] ; then echo hi ; fi ^-> Yes, a binary is called at this place! Note: Bash programmers should use [[ ]] because it is an internal command and therefore much faster (and more powerful).
Close, but not quite right. The ordinary test alias, '[', is a BASH built-in. The variant named '[[' has different semantics and is not necessarily interchangeable in all cases, though it may behave identically in some. To wit: % type [ [ is a shell builtin % type [[ [[ is a shell keyword % help [ [: [ arg... ] This is a synonym for the "test" builtin, but the last argument must be a literal `]', to match the opening `['. [[ ... ]]: [[ expression ]] Returns a status of 0 or 1 depending on the evaluation of the conditional expression EXPRESSION. Expressions are composed of the same primaries used by the `test' builtin, and may be combined using the following operators ( EXPRESSION ) Returns the value of EXPRESSION ! EXPRESSION True if EXPRESSION is false; else false EXPR1 && EXPR2 True if both EXPR1 and EXPR2 are true; else false EXPR1 || EXPR2 True if either EXPR1 or EXPR2 is true; else false When the `==' and `!=' operators are used, the string to the right of the operator is used as a pattern and pattern matching is performed. The && and || operators do not evaluate EXPR2 if EXPR1 is sufficient to determine the expression's value.
...
Markus
Randall Schulz