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



Create a bash shell script that reads in a number from the user. If the number is 1, print out the ..

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

Create a bash shell script that reads in a number from the user. If the number is 1, print out the ..

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

Create a bash shell script that reads in a number from the user. If the number is 1, print out the ..

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

Create a bash shell script that reads in a number from the user. If the number is 1, print out the ..

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

Post New Answer

More Shell Script Interview Questions

What is bourne shell scripting?

0 Answers  


What is the basic difference you find between a shell script and perl?

3 Answers   Yahoo,


What are the different methods available to run a shell script?

2 Answers  


I Forgot My Windows Vista Password! How Can I Find My Windows Lost Password?

1 Answers  


What is meant by $1 in shell script?

0 Answers  






Why is used in shell scripting?

0 Answers  


What language is bash written in?

0 Answers  


I want to create a directory such that anyone in the group can create a file and access any person's file in it but none should be able to delete a file other than the one created by himself.

0 Answers  


Determine the output of the following command: [ -z “” ] && echo 0 || echo 1

0 Answers  


c program the catches the ctrl-c(SIGINT) Signal for the first time and prints a output rather and exit on pressing Ctrl-C again

2 Answers  


on “sed” command EmpData(Sample Database) 1122|j.b. saxena |g.m. |account |12/12/52|6000 2233|n.k. gupta |d.g.m |sales |31/12/40|9000 4545|anil agarwal |director |account |06/07/47|7500 5656|lalit choudhury |executive|marketing|07/09/50|5000 1265|chanchal singhvi|g.m. |admin |12/09/63|6000 0110|shyam saksena |chairman |marketing|12/12/43|8000 5566|jai sharma |director |account |23/12/89|7000 7733|jayant |d.g.m |sales |29/02/70|6000 1. From the above database substitute the delimiter of first 3 lines with “ : “ 2. From the above database substitute the delimiter with “ : ” 3. Insert the string “ XYZ Employees” in the first line. 4. Store the lines pertaining to the directors, d.g.m and g.m into three separate files. 5. Using address store first 4 lines into a file Empupdate. 6. Find the pattern “account” in the database and replaces that with “accounts”. 7. Select those lines which do not have a pattern “g.m”. 8. Insert a blank line after every line in the database.

0 Answers  


What are the default permissions of a file when it is created?

0 Answers  


Categories