Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shell Script -x Flag Meaning

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?

like image 764
Baxter Avatar asked Oct 19 '25 09:10

Baxter


1 Answers

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

like image 169
Teftin Avatar answered Oct 22 '25 03:10

Teftin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!