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
What is scripting used for?
What is shell environment?
How will you emulate wc –l using awk?
What is a shell script? Can you name some of its advantages?
What is the first line in a shell script?
Is cmd a shell?
write a shell script to generate a alert ? like when ur birthday came then generate a alert ur birthday is today like that ?
What is a command line shell?
Explain about debugging?
Write the syntax for "if" conditionals in linux?
How to print pid of the current shell?
How important is shell scripting?
how to print the matrix form of 2-d, 3-d arrays in unix c shell scripts ?
How will you print the login names of all users on a system?
What is difference between bash and shell?