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 / avlsubbarao
#!/bin/bash
echo "Enter Number"
read N
if [ $N == 1 ]; then
date
elif [ $N == 2 ]; then
ls
elif [ $N == 3 ]; then
who
else
echo WRONG NUMBER
fi
| Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
State the advantages of shell scripting?
What is a batch file used for?
How can I send a mail with a compressed file as an attachment?
What is bourne shell scripting?
What is shell prompt?
Write the syntax for "if" conditionals in linux?
When should shell programming/scripting not be used?
What are the advantages of shell scripting?
What does chmod do?
What are zombie processes?
Why is used in shell scripting?
What is shell scripting used for?
What's the difference between scripting and coding?
How does path variable work?
Write a script to print the first 10 elements of fibonacci series.