How do you write if-else in Unix?

Tâm Tây

New member
How do you write if-else in Unix?
Answer
In the following example we will use the == is equal operator to check if the two numbers are equal. #!/bin/sh # take two numbers from the user echo “Enter two numbers: ” read a b # check if [ $a == $b ] then echo “Numbers are equal.” fi echo “End of script.” Output: $ sh if.sh Enter two numbers: 10 20 End of script.
 

Tìm kiếm

Back
Top