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 to get the 3rd element/column from each line from a file?
What is a shell script? Can you name some of its advantages?
How do scripts work?
c program which behaves like a shell(command interpreter). it has its own prompt say "NewShell$".any normal shell command is executed from your shell by starting a child process to execute a system program corrosponding to the command
What is batch file programming?
How to write a function?
How will you connect to a database server from linux?
How to check if the previous command was run successfully?
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?
Why do we use shell scripting?
What is bourne shell scripting?
Explain about echo command?
Explain how you Automate your application using Shell scripting.
Why is shell scripting important?
What is gui scripting?