In one of my shell script, I'm seeing
if [[ ! -d directory1 || ! -L directory ]] ; then
What does -d and -L option mean here? Where can I find information about the options to use in an if condition?
In one of my shell script, I'm seeing
if [[ ! -d directory1 || ! -L directory ]] ; then
What does -d and -L option mean here? Where can I find information about the options to use in an if condition?
You can do help test which will show most of the options accepted by the [[ command.
You can also do help [ which will show additional information. You can do help [[ to get information on that type of conditional.
Also see man bash in the "CONDITIONAL EXPRESSIONS" section.
The -d checks whether the given directory exists. The -L test for a symbolic link.
The File test operators from the Advanced Bash-Scripting Guide explain the various options. And here is the man page for bash which can also be found by typing man bash in the terminal.
bash has built-in help with the help command. You can easily find out the options to a bash built-in using help:
$ help [[
...
Expressions are composed of the same primaries used by the `test' builtin
...
$ help test
test: test [expr]
Evaluate conditional expression.
...
[the answer you want]
In Bourne shell, [ and test were linked to the same executable. Thus, you can find a lot of the various tests available in the test manpage.
This:
if [[ ! -d directory1 || ! -L directory ]] ; then
is saying if directory1 is not a directory or if directory is not a link.
I believe the correct syntax should be:
if [[ ! -d $directory1 ] || [ ! -L $directory ]] ; then
or
if [[ ! -d $directory1 -o ! -L $directory ]] ; then
Is the line in your OP correct?