How to Write Interactive Unix Shell Scripts using Case
Not what you're looking for?
1. Use "vi" to create a shell script copying the following:
#!/bin/bash
echo Select a country from the following list:
echo America, Italy, France, Germany
read country
case $country in
[Aa]merica ) echo Ford; echo Perhpas;;
[Ii]taly ) echo Ferarri; echo no;;
[Ff]rance ) echo Peugeot ;echo no way;;
[Gg]ermany ) echo Porsche ;echo yes;;
esac
· Run the shell script.
2. Create your own shell script that completes the following problem:
§ Ask the user their name
§ Compare it to your name
§ Give a reply that their response is either your name too or it is a nice name too.
Purchase this Solution
Solution Summary
There are two parts of the solution. The first part just executes a pre-defined script.
The second part creates a working shell script to address the following problem.
Creates a shell script that completes the following problem:
§ Ask the user their name
§ Compare it to your name
§ Give a reply that their response is either your name too or it is a nice name too.
The script asks for user's name, then compares with the name stored into a variable $myname inside the script. You can change it's value to anything just make sure you surround it with quotes.
Solution Preview
1. After creating the first shell script it shows the following input / output that were tried on a unix shell prompt ">>"
>>./shScript.sh
Select a country from the following list:
America, Italy, France, Germany
America
Ford
Perhpas
>>/shScript.sh ...
Purchase this Solution
Free BrainMass Quizzes
C# variables and classes
This quiz contains questions about C# classes and variables.
Basic Networking Questions
This quiz consists of some basic networking questions.
Word 2010: Table of Contents
Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.
C++ Operators
This quiz tests a student's knowledge about C++ operators.
Javscript Basics
Quiz on basics of javascript programming language.