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

  Describe implementation of algorithm on simd computer

Describe an implementation of that algorithm on an SIMD computer where the processors are connected to form a linear array

  Create ef?cient algorithm to fnd redundancies

Fnd the redundancies m1, · · · , mn that are within the available budget and that maximize probability that system works correctly. Create an ef?cient algorithm.

  Creating financial tracking program

Acme Inc. is making next generation financial tracking program, and Alice has been provided the task of writing encryption component.

  Explaining playout delay algorithm

Let the adaptive playout delay algorithm. Show through simple example that adjusting playout delay at beginning of each talk.

  Calculate a three quarter moving average forecast

The Fastgro Fertilizer Corporation distributes fertilizer to various lawn and garden shops. Calculate a three-quarter moving average forecast for quarters 4 through 13 and calculate the forecast for each quarter.

  Describe open source and proprietary databases

Describe open source and proprietary databases. What are some drawbacks and benefits of each type of database?

  Explain the three types of relationships

Provide an example of a one to one relationship and an example of a many-to-many relationship in a newspaper, magazine, book, or everyday situation you encounter.

  Write algorithm find intersection of two singly-linked list

Write an algorithm (pseudocode) to find the intersection of two singly-linked lists. Assume that the data in each list are in nondecreasing order.

  Insertion sort and merged using standard merging mechanism

Using "insertion sort" and then merged using standard merging mechanism, where k is value to be determined. How must be we select k in practice?

  Write algorithm to prompt for and accept four numbers

Write the algorithm which will prompt for and accept four numbers, sort them into ascending sequence and display them to screen. Your algorithm is to include module called Order _two_numbers.

  Making visual studio.net web application

Make a Visual Studio.NET 2005 web application with 2-aspx forms. Add a Menu control and a Label control to form. Populate the Menu control with data stored in the "Font" column and show your name in the Label control.

  Describe a fair coin algorithm to returns either 0 or 1

Describe a FAIRCOIN algorithm that returns either 0 or 1 with equal probability, using ONEINTHREE as your only source of randomness.

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