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 / prasad

#!/bin/sh

select num in 1 2 3 any; do
case $num in
1) date;;
2) ls;;
3) who;;
*) echo "Error"; break;;
esac
done

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a script to print the first 10 elements of fibonacci series.

1772


Can we run shell script in windows?

583


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?

642


What are the advantages of shell script?

527


Explain about debugging?

606






What are the zombie processes?

569


What are the different communication commands available in the shell?

522


how to get part of string variable with echo command only?

596


Is shell scripting easy to learn?

571


madhar chod unix ke 10 commands dhang se likh nahi sakta hai

2978


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

2332


What is $1 in shell scripting?

593


What is the difference between break and continue commands?

579


What is a scripting language simple definition?

565


How do I run a .sh file on mac?

682