Using command line options in bash shell script

Assignment Help Data Structure & Algorithms
Reference no: EM1380517

Design a script that will permit the user to enter one of several choices from the command line. The specific requirements are as follows:

[A] Copy one file to another. The user enters the source and destination file to copy to and from. The script shall handle the following cases:
a. Source file name specified does not exist. Script shall display an error message and terminate. Optionally, the script can display an error message and prompt the user to specify the source file name to copy from.
b. Source and destination files both exist. Script shall prompt for permission to overwrite the destination file. If permission is denied, program will display message and terminate.
c. Source file specified with no destination file specified. Script shall display error message and terminate or optionally, it can prompt the user to enter the file name to copy to.

[B] Remove a file if it exists. The user provides the name of the file to remove or delete. Display a message indicating success or failure back to the user and terminates. The script shall handle the following conditions:
a. If the user enters the remove file option but no file name specified the script shall display an error message and terminate or, optionally, display an error message and prompt the user for the file name to remove and remove the file if it exists.
b. If the specified file does not exist the script shall display an error message and terminate.

[C] Display the current day of the week. The script shall allow the user an option to display the day of the week.

[D] Display the month's calendar. The script shall allow the user an option to display the month's calendar.

[E] The script should be named commands.sh and accept options in the command line as either -r or -R for removing a file, -c or -C for copying a file, -d or –D to display the day of the week and –m or –M to display the month's calendar.

[D] If the user enters command.sh without any options the script shall display the usage examples as shown below.

[E] The script shall include the option and the necessary positional parameters information to perform the options as follows:

Copy a file:
prompt$ ./commands.sh –c sourceFile destinationFile
prompt$ ./commands.sh –C sourceFile destinationFile

Remove a file:
prompt$ ./commands.sh –r fileName
prompt$ ./commands.sh –r filename

Display day of week:
prompt$ ./commands.sh –d
prompt$ ./commands.sh –D

Display month's calendar:
prompt$ ./commands.sh –m
prompt$ ./commands.sh –M

 

Reference no: EM1380517

Questions Cloud

How you plan to revise also proofread your final paper : In case of a resume, a single error can put you out of competition. Question - Briefly illustrate conference explain how you plan to revise also proofread your final paper.
What is the foundation of ecuador''s comparative advantage : What is the foundation of Ecuador's comparative advantage in the production of roses? Most Ecuadorean roses are traded in the United States or Europe
Illustrate what result for thomas : Thomas's house is set on fire also burns to ground. Owners of massage parlour also Thomas sue Ralph for negligence.Illustrate what result for massage parlour.
Discuss characteristics of each segmentation strategy : Discuss characteristics of each segmentation strategy; synthesize characteristics also assess explain how an organization determines which one (or more) of strategies to implement.
Using command line options in bash shell script : Design a script that will permit the user to enter one of several choices from the command line. The specific requirements are as follows:
The worlds poorest nations are at a competitive disadvantage : The world's poorest nations are at a competitive disadvantage in every sector of their economies. They have slight to export.
Explain how can content of consumer blogs affect companies : Explain how can content of consumer blogs affect companies. Explain how might blogging by employees adversely affect a company. An employee.
One estimate proposes that if food prices rise : One estimate proposes that if food prices rise by one third they will decrease living standards in rich countries by about three percent however in very poor ones by about twenty percent
Decide whether silas should recover in this case : closing also he sued 18 is enough for damages. 18 is enough defended on basis of limitation of liability provision on parking stub also notice that lot closed at 8:00. Using principles of bailment law, decide whether Silas should recover in this c..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Write algorithm to find median value using queries

As queries are expensive, you would like to calculate median using as few queries as possible. Provide the algorithm which finds median value using at most O(log n) queries.

  Creating an idef1x diagram

Construct an IDEF1X diagram that demonstrate only entities and relationships. Name each relationship and specify its cardinalities.

  Create an idef1x entity relationships diagram

The Metropolitan Housing Agency is a non profit corporation that advocates the development and improvement of low income housing.

  Implementing the banker algorithm

Prompt user to enter the size of matrix n and m. Your program should accept any n x m matrix and m vectors where n and m are positive integer less than ten.

  Queue and content of countdown timer-using priority queue

At time 230 five processes (P1 - P5) are waiting for timeout signal. They are scheduled to wake up at times: 260, 320, 360, 430, 450. Using priority queue with time differences illustrate queue and content of countdown timer at time 230.

  Creating a big inteter calculator program

Create a big-inteter calculator program that permits the user to enter two large integers and the operation to be performed and that calls appropriate function to carry out the designated operation.

  Build b tree for the part table

Build B+ tree for the PART table with n = 6 pointers; illustrate how B+ tree expand (show several intermediate trees) and what final tree will look like.

  Question about java hashtables

Prompt the user for a string, and display the corresponding number. For example, if the user types "five", the program would output "5". This must be done using the hashtable as created in the previous step.

  Creating relational database about music performers

Create a relational database having information about music performers, their recordings, and the composers of the music they recorded.

  Create a solution algorithm using pseudocode

Algorithm that will receive two integer items from a terminal operator, and display to the screen their sum, difference, product and quotient.

  Developing a new application system

Assume you have been assigned as manager on a assignment to develop a new application system for your business partner. You were given 2-weeks to construct a project plan and high level cost estimates.

  Test the database management system functionality

In a report that less than half of all companies validate the in their databases and test database management system's functionality. Explain your answer.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd