The arithmetic operation could be addition, subtraction or multiplication. This examples reads input, which is a type of arithmetic operation wants to perform on bash variables (inp1 and inp2). If you are new to bash scripting, refer to our Bash Introduction tutorial.īash Example 3. The below script reads two integer numbers from user, and checks if both the numbers are equal or greater or lesser than each other. Refer to our previous article to understand the various bash if statement types. The following Bash shell script code-snippet gets the filename with its absolute path, and checks if the file exists or not and it throws the appropriate information. Returns true if either of the expression1 or 2 is true.įor more conditional expression to check the files, strings and numerics please refer the bash man page.Returns true if both the expression is true.Returns true if file exists and its a socket file.Returns true if file exists and executable. Following are few conditional expressions that are helpful. There are several conditional expressions that could be used to test with the files. Conditional expression could be binary or unary expression which involves numeric, string or any commands whose return status is zero when success. Bash expression is the combination of operators, features, or values used to form a bash conditional statement.
0 Comments
Leave a Reply. |