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
How do I open the shell prompt?
How to print all array elements and their respective indexes?
What is meant by $1 in shell script?
how to print the matrix form of 2-d, 3-d arrays in unix c shell scripts ?
How can I set the default rwx permission to all users on every file which is created in the current shell?
Is shell scripting easy to learn?
What makes c shell a more preferable option than the bourne shell?
What is a scripting language simple definition?
What does $0 mean in shell script?
determine the output of the following command: echo ${new:-variable}
What is a shell made of?
What are the different communication commands available in the shell?
How do I set bash as default shell mac?
What are the types of script?
What is bash command used for?