How to use If condition in bash or shell script with examples.
This is a simple bash script or shell script to find greatest of two numbers.
read function used to get input from the user
-gt = Greater than
Note: if you get this message, this means you need to add an execute (x) permission to the bin/greatestOfTwo file.
bash: ./greatestOfTwo.sh: Permission denied
Run the following command
$ chmod +x greatestOfTwo.sh
Now let's execute
$ ./greatestOfTwo.sh Enter First Number: 23 Enter Second Number: 34
Output
Greatest is 34
I hope this may help you.
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login .