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....
-
Stoney Inc. sold bonds with a face value of $100,000 for $104,000. Was the market interest rate equal to, less than, or greater than the bonds' coupon interest rate? Explain.
-
Carlisle Company has been cited and must invest in equipment to reduce stack emissions or face EPA fines of \(\$ 18,500\) per year. An emission reduction filter will cost \(\$ 75,000\) and will have...
-
In consolidation of Perpetual Industries and Sand Hill Company at December 31, 2017, you assemble the following data related to unconfirmed intercompany profits: The equipment is carried on the...
-
The following information is available for Aikman Company. Instructions (a) Compute cost of goods manufactured. (b) Prepare an income statement through gross profit. (c) Show the presentation of the...
-
El mes pasado, Lloyd's Systems analiz el proyecto cuyos flujosde efectivo se muestran a continuacin. Sin embargo, antes de ladecisin de aceptar o rechazar el proyecto, la Reserva Federal tom 1 answer
-
The Dinosaur Adventure Theme Park needs $200 million to build a monorail that will run through the park. The park's financial advisors believe that it will be able to borrow the the money by issuing...
-
Facebook is considering purchasing a new state-of-the-art server farm (several large computers) that would allow the company to match customers pictures to advertisers. The company estimates this new...
-
How do units and dimensions play an important role in characterizing the physical quantities of thermodynamic systems?
-
Distinguish between absolute pressure and gauge pressure. How is it related to the other in case of vacuum?
-
Write short notes on the following: (a) Homogeneous system (b) Heterogeneous system.
-
At what absolute temperature do the Celsius and Fahrenheit scales show the same numerical value?
-
Mention the SI and British units of the following: (a) Pressure (b) Force (c) Temperature (d) Work done (e) Energy (f) Heat (g) Power.
-
Opportunity Cost. Use the concept of opportunity cost to explain the following: a . People prefer to work on holidays with double pay than going on leave. b . CEOs of companies choose to ride a plane...
-
For each equation, (a) Write it in slope-intercept form (b) Give the slope of the line (c) Give the y-intercept (d) Graph the line. 7x - 3y = 3
-
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?
-
Cloud computing has just begun to take off in the business world. The biggest player in the cloud computing marketplace is one you might not expect: Amazon. Under its Web Services division (AWS),...
-
Look around. On the street, at restaurants, sports events, and stores, youll find many people using their smartphones. And many people are starting to use these devices on the job as well. According...
-
The following information for Great Oaks Furniture, a retail furniture and design firm, relates to Exercises 6 through 11. Perform a horizontal analysis of the balance sheets and income statements...
Study smarter with the SolutionInn App