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
What is the purpose of scripting?
What is shell application?
What is the use of echo in shell script?
how will you find the total disk space used by a specific user?
What is inside a seashell?
What are the different types of variables used in shell script?
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.
one folder contains lot of students name but I want to fetch hello with every student name individually using shell script
Devise a script that takes file name as arguement(which must present in the current directory)and locates from your home directory tree all thpath names of its links.Then mail the list to self.
What does it mean by #!/Bin/sh or #!/Bin/bash at the beginning of every script?
What is the difference between break and continue commands?
Explain about the slow execution speed of shells?
How will you print the login names of all users on a system?
How to use arguments in a script?
How do I stop script errors?