Explore BrainMass

A demonstration of various unix shell commands

Copy the following shell that completes the following:

echo Select a country from the following list:
echo America, Italy, France, Germany
read country

case $country in
[Aa]merica ) echo Ford; echo Perhaps;;
[Ii]taly ) echo Ferarri;echo no;;
[Ff]rance ) echo Peugeot ;echo no way;;
[Gg]ermany ) echo Porsche ;echo yes;;


Run the shell from above.

Answer the following questions:
- What is the purpose of the echo command?
- In the case statement, why are the first letters both caps and lower case?
- What does esac mean?

Create your own shell 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.

Solution Preview

The echo command is used to print something to the screen. In this case it is printing a prompt that is asking the user to enter their country.

The first letters of each case in the case statement are enclosed in square brackets ([]) this means that either letter is accepted as a match. Since both an upper and lower case letter are in each ...

Solution Summary

In this solution I provide an explanation of the commands found in a simple shell script. I also write a new shell script that prompts the user for their name and prints a message.