Skip to content

Instantly share code, notes, and snippets.

@nikAizuddin
Created November 30, 2014 20:01
Show Gist options
  • Select an option

  • Save nikAizuddin/8187deaea9987c88bb4a to your computer and use it in GitHub Desktop.

Select an option

Save nikAizuddin/8187deaea9987c88bb4a to your computer and use it in GitHub Desktop.
BCN2053 Operating System Lab Sheet 6 (BASH)
#!/bin/bash
# ==========================================================
# Write a shell script, which will ask you for input 'yes'
# or 'no' and based on that will give you what is your
# input;
#
# a) If you enter yes as your input, it will echo you have
# entered yes.
#
# b) If you enter no as your input, it will echo you have
# entered no.
#
# c) No or invalid input is given, then gives error
# 'no input given'
# ==========================================================
echo "yes or no?"
read answer
if [[ "$answer" = "yes" ]]; then
echo "You have entered yes"
elif [[ "$answer" = "no" ]]; then
echo "You have entered no"
else
echo "No input given"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment