Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # only if
- echo enter a number
- read x
- if [[ $x -gt 10 ]] #if [[ $x -gt 0] ]
- then
- echo number greter then 10
- fi
- # Output
- enter a number
- 12
- number greter then 10
- # If with else
- echo enter a number
- read x
- if [[ $x -gt 10 ]] #if [[ $x -gt 0] ]
- then
- echo number greter then 10
- else
- echo what is physics
- fi
- # Output
- enter a number
- 5
- what is physics
- # with else if
- echo enter a number
- read x
- if [[ $x -lt 0 ]]
- then
- echo number is negative
- elif [[ $x -gt 0 ]]
- then
- echo number is positive
- elif [[ $x -eq 0 ]]
- then
- echo number is zero
- else
- echo you entered something \else
- fi
- # Output
- enter a number
- -21
- number is negative
Advertisement
Add Comment
Please, Sign In to add comment