Implement a program sub that makes a copy of the content of a file substituting one character
Fantastic news! We've Found the answer you've been seeking!
Question:
Implement a program sub
that makes a copy of the content of a file substituting one character for another
The program should print the following help message that explains the functionality of the utility:
Transcribed Image Text:
USAGE: sub [ -h | --fromChars -+toChars [-i inputFile] [-o outputFile DESCRIPTION: This utility copies text from an input stream to an output stream replacing every instance of a specific character in fromChars with a corresponding (position-wise) character from toChars. Any characters in fromChars and in toChars that do not have corresponding counterparts in the other one are ignored. If an input file is provided, the content is read from that file; otherwise, the standard input is used. If an output file is provided, then the modified content is written to that file; otherwise, the standard output is used. OPTIONS: -- (followed by a string without separating space) indicates all characters that will be replaced in the processed text + (followed by a string without separating space) indicates the characters that will be used to replace corresponding (position-wise) characters from fromChars in the processed text -i (followed by input file name) use the provided file as an input stream instead of standard input -o (followed by output file name) use the provided file as an output stream instead of standard output -h prints this help message; it is also a default if no command line arguments are provided Examples $ sub sub -h Both invocation should display the help information for the utility as specified earlier. $ sub --a -+x -i src.txt -o dest.txt $ sub -i src.txt -o dest.txt --a -+x $ sub -o dest.txt --a-i src.txt -+x $ sub--a -o dest.txt -+x -i src.txt All commands with any order of the arguments copy the content of src.txt to dest.txt with all instances of "a" in src.txt replaced by "x" in dest.txt. $ sub --a -+x -i src.txt This will copy the content of src.txt to the standard output with all instances of "a" replaced with "x", $sub-a -+x -o dest.txt This will copy user input from standard input to dest.txt with all instances of "a" replaced with "x". USAGE: sub [ -h | --fromChars -+toChars [-i inputFile] [-o outputFile DESCRIPTION: This utility copies text from an input stream to an output stream replacing every instance of a specific character in fromChars with a corresponding (position-wise) character from toChars. Any characters in fromChars and in toChars that do not have corresponding counterparts in the other one are ignored. If an input file is provided, the content is read from that file; otherwise, the standard input is used. If an output file is provided, then the modified content is written to that file; otherwise, the standard output is used. OPTIONS: -- (followed by a string without separating space) indicates all characters that will be replaced in the processed text + (followed by a string without separating space) indicates the characters that will be used to replace corresponding (position-wise) characters from fromChars in the processed text -i (followed by input file name) use the provided file as an input stream instead of standard input -o (followed by output file name) use the provided file as an output stream instead of standard output -h prints this help message; it is also a default if no command line arguments are provided Examples $ sub sub -h Both invocation should display the help information for the utility as specified earlier. $ sub --a -+x -i src.txt -o dest.txt $ sub -i src.txt -o dest.txt --a -+x $ sub -o dest.txt --a-i src.txt -+x $ sub--a -o dest.txt -+x -i src.txt All commands with any order of the arguments copy the content of src.txt to dest.txt with all instances of "a" in src.txt replaced by "x" in dest.txt. $ sub --a -+x -i src.txt This will copy the content of src.txt to the standard output with all instances of "a" replaced with "x", $sub-a -+x -o dest.txt This will copy user input from standard input to dest.txt with all instances of "a" replaced with "x".
Expert Answer:
Answer rating: 100% (QA)
python code is as follows import argparse import sys def substitutecharactersinputstream outputstrea... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Every Halloween, Peterson s Ice Cream Shop offers a trick - or - treat package of 2 5 coupons for $ 2 0 . The coupons are redeemable by children 1 2 years or under, for a single - scoop cone, with a...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
Suppose that there is parity between the Australian dollar and the United States dollar. Let x be a positive number and assume that the United States dollar increases by 100x % in Australian dollars....
-
Water is forced out of a fire extinguisher by air pressure, as shown in Figure P14.56. How much gauge air pressure in the tank (above atmospheric) is required for the water jet to have a speed of...
-
Is independence impaired when an auditor is hired, paid, and fired by the same corporate managers whose activities are the subject of the audit? Does it matter that in most companies the audit...
-
A sleeve bearing machine on a closed loop oil pumped lubrication system has bearing clearances that are close to specification, yet there is a vibration at exactly 1/2 operating speed. What can be...
-
During its fiscal year ending August 31, 2012, the Eaton School District engaged in the following transactions: It established a purchasing department, to be accounted for in a new internal service...
-
3. [10 points] Consider the following recursive algorithm: Procedure function (double x, int y) { if x = 0, then return 0; else if y = 0, then else return 1; * return x function (x, y - 1); where y...
-
A month has elapsed since Precision Computer Centres year-end. Tony Freedman will use four specialized journals for recording business transactions in the month of Septemberyou will find two in...
-
Problem a) What ate the probabilities of a pit in [1,4] , [2,3], and [3,1] ? Problem b) Which square should the agent move to ? Problem c) What is the most influential quantity that reduced the...
-
Soit le polynme P(x)= x - 2x2 - 5x+6 1) Calculer: P(-1) et P(3). Conclure ? 2) Effectuer la division Euclidienne de P (x) par x - 3 3) Dduire Q(x) tel que: P(x) = (x-3) Q(x). 4) Montrer que -2 est...
-
On November 12th Bloomberg reported that one euro (EUR) cost 20.1802 Mexican pesos (MXN) and that one Peruvian solas (PEN) cost 5.0592 MXN. (a) Are these exchange rates real or nominal? Briefly...
-
14) Use Riemann sums to approximate 2e* +5 dx using n = 4 subintervals. Round your final answer to 4 decimal places. A) Using the Left Endpoint Method Midpoint Method. B) Using the Right Endpoint...
-
A building covers an area of 420 sqft and is built on a parcel of land of an area 525 sqft. Calculate the Floor Space Ratio. (Please enter up to one decimal place)
-
a) A company announces taking on a new project that will generate free cash flows of $6 million per year for 8 years. The company is entirely financed by 5 million shares of stock, with a cost of...
-
What are the main segments of GNSS?
-
For a nonzero constant a, find the intercepts of the graph of (x 2 + y 2 ) 2 = a 2 (x 2 - y 2 ). Then test for symmetry with respect to the x-axis, the y-axis, and the origin.
-
Internet access from smartphones and tablet devices has greatly improved the work environment of long-distance truck drivers. Using your favorite search engine, identify at least three apps that a...
-
How did bulletin board systems and Usenet newsgroups provide early social networking opportunities for Internet users in the 1970s and 1980s?
-
What is a white hat hacker?
-
Suppose Starbucks is considering introducing a new low-calorie blended coffee drink called FrapZero. The firm believes that the drinks flavor and appeal to calorie-conscious drinkers will make it a...
-
By using the yield to maturity on AT&Ts debt, we found that its pretax cost of debt is 3.65%. If AT&Ts tax rate is 25%, what is its effective cost of debt?
-
You work in Walt Disney Companys corporate finance and treasury department and have been assigned to the team estimating Disneys WACC. You must estimate this WACC in preparation for a team meeting...
Study smarter with the SolutionInn App