About the "man test" command

Hello Friends

In Ubuntu if is executed the man test command appears the following:

TEST(1)                                            User Commands                                            TEST(1)

NAME
       test - check file types and compare values

SYNOPSIS
       test EXPRESSION
       test
       [ EXPRESSION ]
       [ ]
       [ OPTION

DESCRIPTION
       Exit with the status determined by EXPRESSION.

...

Observe the following part:

SYNOPSIS
       test EXPRESSION
       test
       [ EXPRESSION ]
       [ ]
       [ OPTION             <-----

Is [ OPTION an error? It should be [ OPTION ] right?

Just being curious

man test [ --help

is valid. So '[ option ’ means [ follow by option.

Now with equal opportunités and all that should it be renamed transexual test ?

Right … because test is an inbuilt shell command … it uses the shell syntax

Hello friends

Thanks for the replies

Howard

man test [ --help
is valid. So '[ option ’ means [ follow by option.

I confirmed it works. Interesting

Neville

Right … because test is an inbuilt shell command … it uses the shell syntax

In what kind of examples is used just only [?

About the if statement I’ve always seen

  • if ...; then
  • if [ ... ]; then
  • if [[ ... ]]; then

Wondered about this kind of syntax

In many (all?) unixes “test” is both an inbuilt and an external command.

Use test for the external command, [ . . . ] for the inbuilt shell command.

The man test and man [ commands appear to give the same output - in fact the two types of test are often hardlinks to the same binary.

" 6.4 Bash Conditional Expressions ¶

Conditional expressions are used by the [[ compound command (see Conditional Constructs) and the test and [ builtin commands (see Bourne Shell Builtins). The test and [ commands determine their behavior based on the number of arguments; see the descriptions of those commands for any other command-specific actions."

I cant find any examples.

[ seems to be a synonym for test … ie you can use [ anywhere you can use the word test

I would have expected the man test command to display a hilarious test of one’s manliness. :smiley:

Things such as:

  1. Do you regurly get into barfights?
  2. Do you eat bricks for breakfast?
  3. Is your car a tank?

Etc.