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
What language is shell scripting?
What is the use of .sh file?
What is in a script?
What is scripting autism?
What is shell prompt?
What is echo $shell?
What is batch file programming?
In my bash shell I want my prompt to be of format '$"present working directory":"hostname"> and load a file containing a list of user-defined functions as soon as I log in, how will you automate this?
What is the purpose of scripting?
Is shell a part of kernel?
What are the zombie processes?
What is the lifespan of a variable inside a shell script?
What is the meaning of $1 in shell script?
What is c in shell script?
madhar chod unix ke 10 commands dhang se likh nahi sakta hai