reqopne.blogg.se

Brackets ubuntu
Brackets ubuntu









brackets ubuntu

When we refer to FILE above we are actually meaning a path.character for character the same) whereas -eq does a numerical comparison meaning will return true. will return false as = does a string comparison (ie. it is not empty).įILE exists and the write permission is granted.įILE exists and the execute permission is granted. INTEGER1 is numerically less than INTEGER2įILE exists and the read permission is granted.įILE exists and it's size is greater than zero (ie. INTEGER1 is numerically greater than INTEGER2 INTEGER1 is numerically equal to INTEGER2 The lengh of STRING is zero (ie it is empty). The length of STRING is greater than zero. Look up the man page for test to see all of the possible operators (there are quite a few) but some of the more common ones are listed below. This means that all of the operators that test allows may be used here as well. The square brackets ( ) in the if statement above are actually a reference to the command test. It is always good practice to test your scripts with input that covers the different scenarios that are possible. If follows the format below:Īnything between then and fi (if backwards) will be executed only if the test (between the square brackets) is true. If it is not true then don't perform those actions. Basic If StatementsĪ basic if statement effectively says, if a particular test is true, then perform a given set of actions. Like what we have looked at in previous sections, their syntax is very specific so stay on top of all the little details. If statements, combined with loops (which we'll look at in the next section) allow us to make much more complex scripts which may solve larger tasks. They allow us to decide whether or not to run a piece of code based upon conditions that we may set. If statements (and, closely related, case statements) allow us to make decisions in our Bash scripts. In this section of our Bash Scripting Tutorial you will learn the ways you may use if statements in your Bash scripts to help automate tasks.











Brackets ubuntu