Question: 2 Pipeline command Complete the main function in pipes.c to implement the following pipeline command: ls / dev | xargs | cut - d -
Pipeline command
Complete the main function in pipes.c to implement the following pipeline command:
ls dev xargs cut df
where d is followed by a white space within singlequotes and and are positive integers
specified as command line arguments of your program.
Lets understand what the pipeline command does. It consists of three external commands, which can
take zero or more arguments, chained together to form a single instruction. The stages of the pipeline
are as follows:
The first stage, ls dev outputs the list of files in dev into a pipe.
The second stage, xargs, takes the output of stage on its standard input, delimits it by
blanks, and sends the output into the second pipe.
The third stage, cut df takes the output of stage as its input and prints
the selected fields in the range a to b on the standard output delimited by a whitespace. Note
that the pair of quotes after d are not needed when passing arguments through execl.
Below are sample outputs from running the program on Github Codespaces. Note that the output may
vary on your local machine. The length of each output, however, should be the same as the below
examples.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
