Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------
- -- Version with [[ .. ]] instead of [ .. ] --
- ---------------------------------------------
- -- Either use --
- -- [ "$1" .. ] --
- -- or --
- -- [[ $1 .. ]] --
- ---------------------------------------------
- #!/bin/bash
- if [[ $1 = apple ]]
- then
- echo "Good, I like Apples"
- elif [[ $1 = pear ]]
- then
- echo "Good, I like Pears"
- elif [[ $1 = banana ]]
- then
- echo "Good, I like Bananas"
- else
- echo "Oh no, I hate Oranges!"
- fi
- ---------------------------------------------
- -- Version with case instead of if --
- ---------------------------------------------
- #!/bin/bash
- case $1 in
- apple)
- echo "Good, I like Apples"
- ;;
- pear)
- echo "Good, I like Pears"
- ;;
- banana)
- echo "Good, I like Bananas"
- ;;
- *)
- echo "Oh no, I hate Oranges!"
- ;;
- esac
Add Comment
Please, Sign In to add comment