Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C shell scripts. please help. Write a C shell scripts that will read data from standard input one character at a time and output the
C shell scripts. please help. Write a C shell scripts that will read data from standard input one character at a time and output the results to standard output. Roughly, your program should mostly copy the input stream to the output stream, but it should delete all numbers [the characters 0 through 9], change the case of alphabetic characters, print two spaces every time you encounter a space, and if you have multiple empty lines in a row, print just one empty line avoid printing the rest. Specifically, for each character you read, do one of the following 4 things: 1) delete all digits (the characters 0, 1, 2, ..., 9); that is, read it in, but then dont print it if was a digit. 2) Interchange the case of the alphabetic letters; that is, if you encounter an A, print out an a instead, B becomes b, etc. and likewise, a becomes A, ... z becomes Z. 3) Every time a space character is encountered (ASCII code 32), print two spaces instead of just the one. 4) When you find consecutive empty lines, print just one empty line. For simplicity, we will distinguish between blank and empty. empty means no characters except for a newline a line consisting of three tabs *looks* blank, but it contains 3 characters, so it will be considered empty. Essentially, this rule simply means if you see a bunch of CONSECUTIVE newlines, print just one newline. 5) All other characters not mentioned above (such as tabs, +, control. characters, or whatever) are simply printed verbatim. Your main program should return a value when it finishes. Return one (1) if the output was unchanged from the input that was read in, and return zero (0) if you made at least one change (either by removing digits, deleting empty lines, doubling spaces, or changing case).
Make sure it reads from stdin and prints to stdout. it should be comprised of standard UNIX utilities (that is, it should not invoke any specialized C programs that you might have considered writing). You must make use of pipes rather than using files to store intermediate result.
Specifically, for each character you read, do one of the following 4 things: 1) delete all digits (the characters 0, 1, 2, ..., 9) that is, read it in, but then don't print it if was a digit. 2) Interchange the case of the alphabetic letters; that is, if you encounter an 'A', print out an 'a' instead, 'B' becomes 'b', etc. and likewise, 'a becomes 'A', 'z' becomes 2' 3) Every time a space character is encountered (ASCII code 32), print two spaces instead of just the one. 4) When you find consecutive empty lines, print just one empty line. For simplicity, we will distinguish between 'blank' and 'empty' empty' means "no characters except for a newline" - a line consisting of three tabs looks* blank, but it contains 3 characters, so it will not be considered empty. Essentially, this rule simply means "if you see a bunch of CONSECUTIVE newlines, print just one newline. 5) All other characters not mentioned above (such as tabs, "+, control characters, or whatever) are simply printed verbatim. Your main program should return a value when it finishes. Return one (1) if the output was unchanged from the input that was read in, and return zero (0) if you made at least one change (either by removing digits, deleting empty lines, doubling spaces, or changing case)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started