Bash Case Matching Linux Example

View previous topic View next topic Go down

Bash Case Matching Linux Example

Post by jamied_uk on 10th August 2016, 13:31




Code:
#!/bin/bash
echo -n "Enter the name of an animal: "
read ANIMAL
echo -n "The $ANIMAL has "
case $ANIMAL in
  horse | dog | cat) echo -n "four";;
  penguine | bird | kangaroo ) echo -n "two";;
  spider | fly ) echo -n "eight";;
  snake | whale ) echo -n "none";;
  *) echo -n "an unknown number of";;
esac
echo " legs."
avatar
jamied_uk
Admin

Posts : 2260
Join date : 2010-05-09
Age : 34
Location : UK

http://address-shortner.co.uk

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum