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


Please Help Members By Posting Answers For Below Questions

What happens when you type ls?

571


What is a scripting language simple definition?

565


What is path in shell script?

641


What is sh in shell script?

581


How do we create command aliases in a shell?

542






What are the advantages of shell script?

527


What is @echo off?

571


What is awk in shell scripting?

560


What are the four fundamental components of every file system on linux?

1168


Is shell and terminal the same?

593


How do I debug a shell script?

570


Please give me example of " at command , contrab command " how to use

2332


What is the first line in every perl script called?

559


What are the different types of shell scripting?

541


What is the use of break command?

590