0

I have an if statement in a bash file:

if [ -f bin/post_compile ]; then
    echo "-----> Running post-compile hook"
    chmod +x bin/post_compile
    sub-env bin/post_compile
fi

what does the -f mean?

3
  • 1
    help test | grep -- -f
    – Cyrus
    Jul 25, 2014 at 17:22
  • [something] is equivalent to test something. As @Cyrus says, lookup test, by typing help test. Jul 25, 2014 at 17:58
  • Why the down-vote, the question is clear. It may be that we think the answer is obvious, but we should not down-vote for being “stupid” (not knowing). Jul 25, 2014 at 18:02

1 Answer 1

5

If the file exists and is a regular file.

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

your statement in English:

If the file "/bin/post_compile" exists and is a regular file then:

  1. Print message
  2. Make the file executable
  3. Execute the file using sub-env

end if (fi)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .