if [-f file]; 是什么意思?意思是?

Jac*_*nta 0 bash

我在 bash 文件中有一个 if 语句:

if [ -f bin/post_compile ]; then
    echo "-----> Running post-compile hook"
    chmod +x bin/post_compile
    sub-env bin/post_compile
fi
Run Code Online (Sandbox Code Playgroud)

是什么-f意思?

Kin*_*tus 5

如果该文件存在并且是常规文件。

http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html

你的英文陈述:

如果文件“/bin/post_compile”存在并且是常规文件,则:

  1. 打印消息
  2. 使文件可执行
  3. 使用执行文件sub-env

万一 (fi