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 / 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 |
Post New Answer View All Answers
How to use arguments in a script?
How to replace following lines, catch (DAOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } catch (BOException e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw e; } catch (Exception e) { objLogger.error(this.getClass () + "addUpdateIssues() " + e); throw new BOException(5122); } Needs to be changed in to, catch (DAOException e) { AppException.handleException (null, null, e, null, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); } catch (BOException e) { AppException.handleException (null, null, null, e, null, null, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 0); } catch (Exception e) { AppException.handleException (null, null, null, null, null, e, "BOException", this.getClass() + "addUpdateIssues() ", null, null, null, null, null, null, null, null, 5122); }
Can shell script run on windows?
How to calculate the number of passed arguments?
In my bash shell I want my prompt to be of format '$"present working directory":"hostname"> and load a file containing a list of user-defined functions as soon as I log in, how will you automate this?
What language is used in terminal?
How can any user find out all information about a specific user like his default shell, real-life name, default directory, when and how long he has been using the system?
How do I read a .sh file?
When should shell programming/scripting not be used?
Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.
What makes c shell a more preferable option than the bourne shell?
What is shell environment?
What is the difference between bash and shell?
How to find all the files modified in less than 3 days and save the record in a text file?
What is path variable bash?