Question: This program is to be done in C program language And i need complete code with the screenshot of the output. I have also provided
Exercise 1. (100 points) runpipeline A pipeline is a sequence of external programs chained together to perform a task. The standard output of stage i of the pipeline is fed to the standard input of stage i +1. In sbells like bash, stages are separated by ". For example, the following papeline that coutains 7 stages counts the mualer of occurrences of each word in a text file. The solutions repo under sol-hu5. You can also try other text files, for example, your C souce code output of the last stage is redirected into file counts.tit. whitman.txt is in the cat vhitaan.tat I tr - space: ' I tr -d Epact: I tr A-Z a-z I sortI i-I ore -r > The seven stages do the following The command in each stage prints its result to atdout and the output of the last command is redirected to counta.txt 1. Send the coatents of the file whitman.txt to stdout 2 Replace every sequence of consecutive spaces in stdin with a single line Seed 3. Delete all punctuation characters from stdin and send remaining characters to stdout 4. Replace uppercase letters in stdin with lowercase letters 5. Sort the lines from stdin alphabetically 6. Collapse adjacent matching lines to ai single copy preceded by the umber of copies 7. Sort the lines from stdin in reverse mnerical order In this problem. you will compete the functions in runpipeline.c the program can start a pipeline mith the programs specified at the command line. To avoid interference with the shell, pipeline stages are separated with , instead of .To run the above bash pipeline with runpipeline, you woukd run the following cmand in bash and the resulting counts.txt should be the sme Join two lines when you try the command runpipeline eat vhitean.txt [:space:)tr -d [pet:tr -Z a-e In runpipeline.c, the commands for all stages are already stored in an array of Progran structures, hich are defined as follows. l eypedef struet progran tng Pid; process tD of this pregran fd.out; // ?1pe f4 .r st4est Progan The-\" al the end of first lize alluws the pipelinc cusumands to cu tinue. the Kal yuu aa-juat juin Lhe two lines when you try the pipeline in hash. arga [0] is the command and args is the array of anguments to be losed to an execv. function. .arga is the mullber of arguments in args. pid s the proces ID of the child process Sor this command. If fd-in is non-negative, the file descriptor will be used for stdin for the cotamad If .out is Don-aegative, it will be tied for tdout for the command. Note that runpipeline does not redirect the input or output for the pipeline itsel. If needed, the redirection can be set on runpipeline by the shell Then the first command in the pipeline can have Exercise 1. (100 points) runpipeline A pipeline is a sequence of external programs chained together to perform a task. The standard output of stage i of the pipeline is fed to the standard input of stage i +1. In sbells like bash, stages are separated by ". For example, the following papeline that coutains 7 stages counts the mualer of occurrences of each word in a text file. The solutions repo under sol-hu5. You can also try other text files, for example, your C souce code output of the last stage is redirected into file counts.tit. whitman.txt is in the cat vhitaan.tat I tr - space: ' I tr -d Epact: I tr A-Z a-z I sortI i-I ore -r > The seven stages do the following The command in each stage prints its result to atdout and the output of the last command is redirected to counta.txt 1. Send the coatents of the file whitman.txt to stdout 2 Replace every sequence of consecutive spaces in stdin with a single line Seed 3. Delete all punctuation characters from stdin and send remaining characters to stdout 4. Replace uppercase letters in stdin with lowercase letters 5. Sort the lines from stdin alphabetically 6. Collapse adjacent matching lines to ai single copy preceded by the umber of copies 7. Sort the lines from stdin in reverse mnerical order In this problem. you will compete the functions in runpipeline.c the program can start a pipeline mith the programs specified at the command line. To avoid interference with the shell, pipeline stages are separated with , instead of .To run the above bash pipeline with runpipeline, you woukd run the following cmand in bash and the resulting counts.txt should be the sme Join two lines when you try the command runpipeline eat vhitean.txt [:space:)tr -d [pet:tr -Z a-e In runpipeline.c, the commands for all stages are already stored in an array of Progran structures, hich are defined as follows. l eypedef struet progran tng Pid; process tD of this pregran fd.out; // ?1pe f4 .r st4est Progan The-\" al the end of first lize alluws the pipelinc cusumands to cu tinue. the Kal yuu aa-juat juin Lhe two lines when you try the pipeline in hash. arga [0] is the command and args is the array of anguments to be losed to an execv. function. .arga is the mullber of arguments in args. pid s the proces ID of the child process Sor this command. If fd-in is non-negative, the file descriptor will be used for stdin for the cotamad If .out is Don-aegative, it will be tied for tdout for the command. Note that runpipeline does not redirect the input or output for the pipeline itsel. If needed, the redirection can be set on runpipeline by the shell Then the first command in the pipeline can have
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
