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

Explain about debugging?

680


What is shell geeksforgeeks?

665


What is a shell script in windows?

656


wats the deinitions for shell utility and filter?

1936


What are filters explain sort with all the options available?

1033






Why are shell scripts used?

695


What is another name for a bash shell script that you might see?

1101


What is a boot block?

668


How to check if the previous command was run successfully?

665


I have to write Shells (Linux + Unix)for publishing packages and reports. Is it possible ? What are the differents executable programs ineed to call ?

1749


How do you create a shortcut in linux?

674


What is option in shell script?

630


Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.

817


What's the difference between scripting and coding?

696


What is sudo command?

629