shell测试('[')命令中-e选项的含义是什么?

Pet*_*ete 1 shell command

我在Linux中使用shell命令,我找到了这个命令:

while [ ! -e /tmp/.wm_ready ]; do sleep 0.1 ; done
Run Code Online (Sandbox Code Playgroud)

我认为这个命令会sleep 0.1s/tmp/.wm_ready创建之前完成.

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

Rah*_*thi 6

它是检查FILE是否存在.有关详细信息,请参阅手册.

-e FILE
    FILE exists
Run Code Online (Sandbox Code Playgroud)

另外一点是这里有一些其他有用的选择

   -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
Run Code Online (Sandbox Code Playgroud)