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
How are shells born?
How will you emulate wc –l using awk?
Using set -A write a script to print the output of the ls command in 5 columns with two spaces between each column. Pretend that ls does not have multicolumn output.
What is the first line of a shell script called?
Which is better perl or shell scripting?
Explain about login shell?
How to get the 3rd element/column from each line from a file?
How do I read a .sh file?
how to print the matrix form of 2-d, 3-d arrays in unix c shell scripts ?
What is shell scripting used for?
What is the best shell scripting language?
What are the four fundamental components of every file system on linux?
Why is shell scripting important?
Explain about stdin, stdout and stderr?
madhar chod unix ke 10 commands dhang se likh nahi sakta hai