What is another way of specifying the test command in bash?



  • The test command with bash can be used on the command line or in a shell script.

    e.g. : of the command line usage.

    $ test -d /var/log/samba || echo "Log directory does not exist"
    Log directory does not exist
    

    Another way of specifying the test command can be written as follows: the test keyword is dropped. The square brackets are used.

    $ [ -d /var/log/samba ] || echo "Log directory does not exist"
    Log directory does not exist
    

Log in to reply
 

© Lightnetics 2024