Bax*_*ter 1 shell flags if-statement sh
我有一个#!/ bin/sh脚本,其中包含以下行:
if [ ! -x "$TEST_SLAPD" ]
Run Code Online (Sandbox Code Playgroud)
$TEST_SLAPD 是.bat文件的完整路径.
我想知道-x该if声明在该声明的背景下意味着什么?
小智 7
if只检查它后面的命令结果.[不是(至少不总是)一个运算符,它的小实用程序称为'test'.
从其文件:
-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.
Run Code Online (Sandbox Code Playgroud)
(是的,!显然是否定的)
对于类似的evualation标志,可在此处获取文档:http://illumos.org/man/1/test