Shell 脚本 -x 标志含义

标签 shell if-statement sh flags

我有一个 #!/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/

相关文章:

javascript - 从 UI 触发批处理文件

shell - linux shell 日期连接

jquery - 如何检测窗口大小,然后用 jquery switch 语句做一些事情

bash - Cshell 中的反向增量搜索

linux - 如何等待变量的值在特定时间间隔之前设置为 true

javascript - Node js 如果条件不能正常工作

java - 使用递归方法通过控制流中断 Java 循环的迭代

Linux shell 脚本按字母顺序对文本行进行反向排序(最好不使用排序)

linux - 期望脚本在一定时间内等待特定输入

sh - sed 命令/shell 脚本读取特定行并根据需要更新它