shell test ('[') 命令中的 -e 选项是什么意思?

What is the meaning of -e option in a shell test ('[') command?

我在 Linux 中使用 shell 命令,我发现了这个命令:

while [ ! -e /tmp/.wm_ready ]; do sleep 0.1 ; done

我认为此命令会执行 sleep 0.1s 直到创建 /tmp/.wm_ready

但是我不知道-e选项是什么。谁能帮我解决这个问题?

请参阅 shell 的手册。在我的(ksh93 on Mac OS X 10.10.3)中,它说:

-e file
   True, if file exists.

检查FILE是否存在。详情可参考manual

-e FILE
    FILE exists

附注是一些其他有用的选项

   -d FILE
          FILE exists and is a directory
   -e FILE
          FILE exists
   -f FILE
          FILE exists and is a regular file
   -h FILE
          FILE exists and is a symbolic link (same as -L)
   -r FILE
          FILE exists and is readable
   -s FILE
          FILE exists and has a size greater than zero
   -w FILE
          FILE exists and is writable
   -x FILE
          FILE exists and is executable
   -z STRING
          the length of STRING is zero

明确地说,-e 选项检查 filedirectory(符号 links包括)。

条件

[ ! -e /tmp/.wm_ready ]

检查tmp 文件夹

中是否不存在名称为.wm_ready 的任何文件或目录或符号link