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"
Answers were Sorted based on User's Feedback
Answer / aryan
cho "Enter Choice"
read num
case $num in
1) echo `date`
;;
2) ls
;;
3) who
;;
*) echo "Wrong option press 1 2 3 only"
;;
esac
| Is This Answer Correct ? | 8 Yes | 0 No |
Answer / kasu
echo "Enter the number"
read i
if [ $i -eq 1 ];then
echo `date`
elif [ $i -eq 2 ];then
ls
elif [ $i -eq 3 ];then
who
else
echo "Nothing"
fi
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / 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 |
Answer / 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 |
How can you find out how long the system has been running?
What does $$ mean in shell script?
Hello all, This is my assignment on shell scripting, can anyone help me regarding this ? Create a shell script which connects to the database In second shell script include the first script for the DB connection Create a table (PRADEEP_DATA) with 2 columns (name, value) In Third shell script include the first script for the DB connection And insert/delete the values from the Table, by accepting input from the user This functionality should be a menu driven Program: 1) Insert to the database a. Name b. value 2)Delete from the database a.Name b.value Exception handling needs to be taken care.
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.
State the advantages of shell scripting?
What are the four fundamental components of every file system on linux?
What does $@ mean bash?
How will you connect to a database server from linux?
Is shell scripting a language?
Where is bash history?
c program to implement unix/linux command to block the signal ctrl-c and ctrl-\ signal during the execution ls -l|wc -l
What is the syntax of "nested if statement" in shell scripting?