bash -f 是什么意思

What does -f mean in bash

我正在研究如何使用 runit to run gunicorn。我正在查看 bash 文件,但我不知道 -f $PID

中做了什么
#!/bin/sh

GUNICORN=/usr/local/bin/gunicorn
ROOT=/path/to/project
PID=/var/run/gunicorn.pid

APP=main:application

if [ -f $PID ]; then rm $PID; fi

cd $ROOT
exec $GUNICORN -c $ROOT/gunicorn.conf.py --pid=$PID $APP

Google 在这种情况下是无用的,因为搜索标志是无用的

-f 检查文件是否存在并且是一个普通文件。

-f - file is a regular file (not a directory or device file)

检查所有文件测试操作符: http://tldp.org/LDP/abs/html/fto.html

[ 与命令 test 相同,它允许您测试某些东西。尝试 help test 找出标志是什么。需要注意的是 spaces - [ 后面需要一个 space。

Google is useless in this case because searching for flags is useless

幸运的是,Bash 参考手册 可以在线获取,在 http://www.gnu.org/software/bash/manual/bashref.html. It's the first hit when you Google for "Bash manual". §6.4 "Bash Conditional Expressions" 上说:

-f <em>file</em>

True if file exists and is a regular file.

[ -f "$var" ] 

检查 $var 是否为现有文件(常规文件)。 Symbolic link 也通过了这个测试。