Reputation: 5845
I have a #!/bin/sh script that has the following line:
if [ ! -x "$TEST_SLAPD" ]
$TEST_SLAPD
is the full path to a .bat file.
I am wondering what the -x
flag means in the context of that if
statement?
Upvotes: 4
Views: 19822
Reputation: 846
if
just checks for result of command following it. [
is not (at least not always) an operator, it's small utility called 'test'.
From its documentation:
-x file
True if file exists and is exe-
cutable. True indicates only
that the execute flag is on. If
file is a directory, true indi-
cates that file can be searched.
(and yes, !
is obviously negation)
For similar evualation flags, documentation is available here: http://illumos.org/man/1/test
Upvotes: 11
Reputation: 84343
The ! -x
conditional means the file or directory doesn't have the executable bit set for the current user. The help is a little less clear about the fact that it applies to directories too, but it says:
$ help test | fgrep -- '-x'
-x FILE True if the file is executable by you.
Upvotes: 3