我有一个 #!/bin/sh 脚本,其中包含以下行:
if [ ! -x "$TEST_SLAPD" ]
$TEST_SLAPD
是 .bat 文件的完整路径。我想知道是什么
-x
标志意味着在 if
的上下文中陈述?
最佳答案
if
只检查跟随它的命令的结果。 [
不是(至少不总是)运算符,它是一个名为“测试”的小实用程序。
从它的文档:
-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.
(是的,
!
显然是否定的)对于类似的评估标志,文档可在此处获得:http://illumos.org/man/1/test
关于Shell 脚本 -x 标志含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11058794/