Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does -f mean in bash

Tags:

operators

bash

I was looking at how to use runit to run gunicorn. I was looking at the bash file and I don't know what -f $PID does in

#!/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 is useless in this case because searching for flags is useless

like image 363
Atrotors Avatar asked Jun 14 '15 03:06

Atrotors


People also ask

What does $? Mean in bash?

$? - It gives the value stored in the variable "?". Some similar special parameters in BASH are 1,2,*,# ( Normally seen in echo command as $1 ,$2 , $* , $# , etc., ) . Follow this answer to receive notifications. edited Jun 20, 2020 at 9:12. CommunityBot.

What does [- Z $1 mean in bash?

$1 means an input argument and -z means non-defined or empty. You're testing whether an input argument to the script was defined when running the script. Follow this answer to receive notifications.

What does $# represent in shell scripting?

$# : This variable contains the number of arguments supplied to the script. $? : The exit status of the last command executed. Most commands return 0 if they were successful and 1 if they were unsuccessful. Comments in shell scripting start with # symbol.


1 Answers

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

Fortunately, the Bash Reference Manual is available online, at 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" says:

-f file

True if file exists and is a regular file.

like image 179
ruakh Avatar answered Oct 02 '22 11:10

ruakh