Create a bash shell script that reads in a number from the
user. If the number is 1, print out the date. If the number
is 2, list the files in the current directory. If the number
is 3, print out who is currently logged onto the system. If
the number is anything else, print out an error message and
exit. Name this script "various.sh"

Answer Posted / kasu

echo "Enter the number"
read i
if [ $i -eq 1 ];then
echo `date`
elif [ $i -eq 2 ];then
ls
elif [ $i -eq 3 ];then
who
else
echo "Nothing"
fi

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I open the shell prompt?

681


How to print all array elements and their respective indexes?

576


What is meant by $1 in shell script?

628


how to print the matrix form of 2-d, 3-d arrays in unix c shell scripts ?

3704


How can I set the default rwx permission to all users on every file which is created in the current shell?

1043






Is shell scripting easy to learn?

650


What makes c shell a more preferable option than the bourne shell?

624


What is a scripting language simple definition?

658


What does $0 mean in shell script?

645


determine the output of the following command: echo ${new:-variable}

626


What is a shell made of?

644


What are the different communication commands available in the shell?

594


How do I set bash as default shell mac?

650


What are the types of script?

687


What is bash command used for?

659