What does -f mean in bash

后端 未结 5 1451
北荒
北荒 2021-01-17 09:23

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=/us         


        
相关标签:
5条回答
  • 2021-01-17 10:01

    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.

    0 讨论(0)
  • 2021-01-17 10:05
    [ -f "$var" ] 
    

    Checks if $var is an existing file (regular file). Symbolic link passes this test too.

    0 讨论(0)
  • 2021-01-17 10:20

    -f checks if the file exists and is a regular file.

    0 讨论(0)
  • 2021-01-17 10:23

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

    Check this out for all file test operators: http://tldp.org/LDP/abs/html/fto.html

    0 讨论(0)
  • 2021-01-17 10:23

    The [ is the same as the command test which allows you to test certain things. Try help test to find out what the flags are. Things to be careful with are spaces - the [ needs a space after it.

    0 讨论(0)
提交回复
热议问题