Limited Offer Get 25% off — use code BESTW25
No AI No Plagiarism On-Time Delivery Free Revisions
Claim Now

COP 4338 Systems Programming- chaining the standard Unix

Task:

In this assignment, you are asked to implement functions by chaining the standard Unix utility programs. In particular, you are asked to produce a program that searches an input file, selects the lines that match a given regular expression, and sorts the matched lines in reverse order.

Your program should take three arguments:

You are not expected to implement the specific functions, such as matching a regular expression or sorting the lines in reverse order. Rather, you should be using existing Unix utility programs:

1. grep is a utility program which is a file pattern searcher. It takes one command-line argument (the PATTERN string in our case) and search for matches line by line from the standard input (or the file specified as the second command-line argument). When a match is found (a line that matches with the PATTERN string), the program prints the line to the standard output. The utility program outputs all matched lines.

2. sort is a utility program that sorts the text file by lines. By default, it reads from the standard input and generates the sorted text to the standard output. Use -r option to sort in reverse order. 

3. Your program should use fork and exec system calls to run the utility programs. You should also use pipe and dup/dup2 system calls to connect them, so that, for example, the standard output of the grep program is “piped” to the standard input of the sort program.

Read less
Plagiarism Free Assignment Help

Expert Help With This Assignment — On Your Terms

Native UK, USA & Australia writers Deadline from 3 hours 100% Plagiarism-Free — Turnitin included Unlimited free revisions Free to submit — compare quotes