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
How can I set the default rwx permission to all users on every file which is created in the current shell?
Where are cowrie shells found?
What is the syntax of while loop in shell scripting?
How does ls command work?
How to redirect both standard output and standard error to the same location?
How to print all the arguments provided to the script?
What is batch file programming?
c program to display the information of given file similar to givan by the unix or linux command ls -l
What is a shell environment?
Explain about stdin, stdout and stderr?
What is shell variable?
What does sh mean?
What is bash shell command?
What is an sh file?
how to print the 2-d, 3-d arrays in unix shell script programs please answer thi questio to my mail venusaikumar@gmail.com