$20 Bonus + 25% OFF
Securing Higher Grades Costing Your Pocket?
Book Your Assignment at The Lowest Price
Now!
Students Who Viewed This Also Studied
COP4338 Systems Programming
Question:
Programming in C language
Description
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:
$ ./grepsort PATTERN INPUTFILE OUTPUTFILE
where PATTERN is a simple string or a simple regular expression. INPUTFILE is the name of the input file, and OUTPUTFILE is the name of the output file for the result.
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:
*grepis 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.
*sortis 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.
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.
Implementation
You are advised to follow the steps below in your implementation:
a. Open input file for read
b. Open output file for write
c. Create a pipe
d. Fork
e. In the parent process:
-Use dup/dup2 to make opened input file as standard input
-Use dup/dup2 to make the write end of the pipe as standard output
-Close the open files not used (such as the output file and the read end of the pipe)
-Use exec to run grep PATTERN
f. In the child process:
-Use dup/dup2 to make the read end of the pipe as standard input
-Use dup/dup2 to make opened output file as standard output
-Close unused open files
-Use exec to run sort -r
-To test your program is running correctly, you can compare the result (in the output file) against running the following command. They should match.
% grep PATTERN OUTPUTFILE.
COP4338 Systems Programming
Answer in Detail
Solved by qualified expert
Get Access to This Answer
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Hac habitasse platea dictumst vestibulum rhoncus est pellentesque. Amet dictum sit amet justo donec enim diam vulputate ut. Neque convallis a cras semper auctor neque vitae. Elit at imperdiet dui accumsan. Nisl condimentum id venenatis a condimentum vitae sapien pellentesque. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Malesuada fames ac turpis egestas maecenas pharetra convallis posuere. Et ultrices neque ornare aenean euismod. Suscipit tellus mauris a diam maecenas sed enim. Potenti nullam ac tortor vitae purus faucibus ornare. Morbi tristique senectus et netus et malesuada. Morbi tristique senectus et netus et malesuada. Tellus pellentesque eu tincidunt tortor aliquam. Sit amet purus gravida quis blandit. Nec feugiat in fermentum posuere urna. Vel orci porta non pulvinar neque laoreet suspendisse interdum. Ultricies tristique nulla aliquet enim tortor at auctor urna. Orci sagittis eu volutpat odio facilisis mauris sit amet.
Tellus molestie nunc non blandit massa enim nec dui. Tellus molestie nunc non blandit massa enim nec dui. Ac tortor vitae purus faucibus ornare suspendisse sed nisi. Pharetra et ultrices neque ornare aenean euismod. Pretium viverra suspendisse potenti nullam ac tortor vitae. Morbi quis commodo odio aenean sed. At consectetur lorem donec massa sapien faucibus et. Nisi quis eleifend quam adipiscing vitae proin sagittis nisl rhoncus. Duis at tellus at urna condimentum mattis pellentesque. Vivamus at augue eget arcu dictum varius duis at. Justo donec enim diam vulputate ut. Blandit libero volutpat sed cras ornare arcu. Ac felis donec et odio pellentesque diam volutpat commodo. Convallis a cras semper auctor neque. Tempus iaculis urna id volutpat lacus. Tortor consequat id porta nibh.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Hac habitasse platea dictumst vestibulum rhoncus est pellentesque. Amet dictum sit amet justo donec enim diam vulputate ut. Neque convallis a cras semper auctor neque vitae. Elit at imperdiet dui accumsan. Nisl condimentum id venenatis a condimentum vitae sapien pellentesque. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Malesuada fames ac turpis egestas maecenas pharetra convallis posuere. Et ultrices neque ornare aenean euismod. Suscipit tellus mauris a diam maecenas sed enim. Potenti nullam ac tortor vitae purus faucibus ornare. Morbi tristique senectus et netus et malesuada. Morbi tristique senectus et netus et malesuada. Tellus pellentesque eu tincidunt tortor aliquam. Sit amet purus gravida quis blandit. Nec feugiat in fermentum posuere urna. Vel orci porta non pulvinar neque laoreet suspendisse interdum. Ultricies tristique nulla aliquet enim tortor at auctor urna. Orci sagittis eu volutpat odio facilisis mauris sit amet.
Tellus molestie nunc non blandit massa enim nec dui. Tellus molestie nunc non blandit massa enim nec dui. Ac tortor vitae purus faucibus ornare suspendisse sed nisi. Pharetra et ultrices neque ornare aenean euismod. Pretium viverra suspendisse potenti nullam ac tortor vitae. Morbi quis commodo odio aenean sed. At consectetur lorem donec massa sapien faucibus et. Nisi quis eleifend quam adipiscing vitae proin sagittis nisl rhoncus. Duis at tellus at urna condimentum mattis pellentesque. Vivamus at augue eget arcu dictum varius duis at. Justo donec enim diam vulputate ut. Blandit libero volutpat sed cras ornare arcu. Ac felis donec et odio pellentesque diam volutpat commodo. Convallis a cras semper auctor neque. Tempus iaculis urna id volutpat lacus. Tortor consequat id porta nibh.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Hac habitasse platea dictumst vestibulum rhoncus est pellentesque. Amet dictum sit amet justo donec enim diam vulputate ut. Neque convallis a cras semper auctor neque vitae. Elit at imperdiet dui accumsan. Nisl condimentum id venenatis a condimentum vitae sapien pellentesque. Imperdiet massa tincidunt nunc pulvinar sapien et ligula. Malesuada fames ac turpis egestas maecenas pharetra convallis posuere. Et ultrices neque ornare aenean euismod. Suscipit tellus mauris a diam maecenas sed enim. Potenti nullam ac tortor vitae purus faucibus ornare. Morbi tristique senectus et netus et malesuada. Morbi tristique senectus et netus et malesuada. Tellus pellentesque eu tincidunt tortor aliquam. Sit amet purus gravida quis blandit. Nec feugiat in fermentum posuere urna. Vel orci porta non pulvinar neque laoreet suspendisse interdum. Ultricies tristique nulla aliquet enim tortor at auctor urna. Orci sagittis eu volutpat odio facilisis mauris sit amet.
Tellus molestie nunc non blandit massa enim nec dui. Tellus molestie nunc non blandit massa enim nec dui. Ac tortor vitae purus faucibus ornare suspendisse sed nisi. Pharetra et ultrices neque ornare aenean euismod. Pretium viverra suspendisse potenti nullam ac tortor vitae. Morbi quis commodo odio aenean sed. At consectetur lorem donec massa sapien faucibus et. Nisi quis eleifend quam adipiscing vitae proin sagittis nisl rhoncus. Duis at tellus at urna condimentum mattis pellentesque. Vivamus at augue eget arcu dictum varius duis at. Justo donec enim diam vulputate ut. Blandit libero volutpat sed cras ornare arcu. Ac felis donec et odio pellentesque diam volutpat commodo. Convallis a cras semper auctor neque. Tempus iaculis urna id volutpat lacus. Tortor consequat id porta nibh.
15 More Pages to Come in This Document. Get access to the complete answer.
All your worries related to custom essay writing come to an end at MyAssignmenthelp.com. We provide online assignment help to students in US, UK, Singapore, Australia, Canada and UAE. Apart from custom essay help, our 3000+ PhD level expert writers provide academic assignment help in over 100 subjects. Our writers provide assignment help services related to homework writing and dissertation writing too. If you need any custom essay or other assignment related suggestion then contact us through our 24/7 live chat support facility. We have a talented staff that can address all your assignment queries and also convey your customizations to the concerned writer who will be framing your custom essay help material.
More COP 4338 COP4338 Systems Programming: Questions & Answers
Computer Organization
SCANNERConverts the stream of characters from the input medium into an internal formatsuited for use by the CompilerIdentify the TOKENS of the languageRemove extraneous blanks and other white spaceRemove commentsReport errors discoveredThe SCANNER examines the text, character by character, identifyi …
View Answer
B9DA104 Machine Leraning
Task:
Define the following
Define Data pre-processing and its steps with examples.
Define Decision tree, Information gain and Entropy.
Define Chinese restaurant algorithm with example.
Regression model
Classification model
Program the following
Please select any data from h …
View Answer
Business Management
Details For this assignment, you are required to develop a Java Console Program to demonstrate you can use Java constructs including input/output via a command line, Java primitive and built-in data types, Java defined objects, selection and looping statements, methods, and various other Java …
View Answer
SIT105 Critical Thinking and Problem Solving for IT
Objectives:There are several goals for the assignment:• To demonstrate your understanding of some of the concepts behind programming;• To demonstrate a methodical approach to solving problems; and• To design and develop algorithms using sequence, selection and iterative constructs and …
View Answer
Content Removal Request
If you are the original writer of this content and no longer wish to have your work published on Myassignmenthelp.com then please raise the
content removal request.
Choose Our Best Expert to Help You
Khloe Pierce
Pharmaceutical and Biomedical Sciences, M.Sc from the University of Georgia
650 – Completed Orders
Hire Me
Cooper Cassidy
Master of Information Technology with Specialization in Networks and Information Security
2779 – Completed Orders
Hire Me
Still in Two Minds? The Proof is in Numbers!
33845 Genuine Reviews With a Rating of 4.9/5.
Assignment
Assignment: 4 Pages, Deadline:
5 days
My assignment helper is so amazing, she did my work before my requirement dead line.
User ID: 8***98 United States
Programing
Programming: 11.2 Pages, Deadline:
3 days
Python coding assignment work completed well. This assignment was done thoroughly and was in correct format. However there were some few small errors
User ID: 8***31 United States
Accounting
Programming: 8 Pages, Deadline:
14 days
Great writing and referencing snsjsnsnsndndndbbxdbndkajznzmzmkeidndbfjdbr jddhhd s j
User ID: 8***81 United Arab Emirates
Finance
Home Work: 1 Page, Deadline:
4 days
Lectuerer had replied that the 3 questions are good, please procced with the assisgnment. Thank you.
User ID: 8***50 Singapore
Psychology
Home Work: 1 Page, Deadline:
21 hours
Recieved help with my assignment and received it a few hours earlier than deadline which was awesome!
User ID: 8***08 United States
Finance
Home Work: 4 Pages, Deadline:
2 days
It was a very nice written piece of paper. Good referencing. Well written, i got almost 60. I think writers should improve more
User ID: 6***62 Greece
Management
Assignment: 4 Pages, Deadline:
5 days
Great work and formatting. The rubric was followed and your help certainly bumped up my grades. Thank you for your help!!
User ID: 1***16 Mississauga, Canada
Supply Chain
Assignment: 2 Pages, Deadline:
5 days
I am delighted with expert work this time because the assignment is written with excellent words and less similarity.
User ID: 7***43 Australia
Statistics
Thesis: 19 Pages, Deadline:
9 days
Assignment was good. and i scored the amount i was looking for. passed all assignments
User ID: 3***26 Male, Maldives
Statistics
Programming: 2.4 Pages, Deadline:
4 days
Perfect score, the assignment was excellently done, great service, the professor, said excellent grade. I will continue using this service for all my …
User ID: 1***17 New York, United States
Assignment
Assignment: 4 Pages, Deadline:
5 days
My assignment helper is so amazing, she did my work before my requirement dead line.
User ID: 8***98 United States
Programing
Programming: 11.2 Pages, Deadline:
3 days
Python coding assignment work completed well. This assignment was done thoroughly and was in correct format. However there were some few small errors
User ID: 8***31 United States
Accounting
Programming: 8 Pages, Deadline:
14 days
Great writing and referencing snsjsnsnsndndndbbxdbndkajznzmzmkeidndbfjdbr jddhhd s j
User ID: 8***81 United Arab Emirates
Finance
Home Work: 1 Page, Deadline:
4 days
Lectuerer had replied that the 3 questions are good, please procced with the assisgnment. Thank you.
User ID: 8***50 Singapore
Psychology
Home Work: 1 Page, Deadline:
21 hours
Recieved help with my assignment and received it a few hours earlier than deadline which was awesome!
User ID: 8***08 United States
Finance
Home Work: 4 Pages, Deadline:
2 days
It was a very nice written piece of paper. Good referencing. Well written, i got almost 60. I think writers should improve more
User ID: 6***62 Greece
Management
Assignment: 4 Pages, Deadline:
5 days
Great work and formatting. The rubric was followed and your help certainly bumped up my grades. Thank you for your help!!
User ID: 1***16 Mississauga, Canada
Supply Chain
Assignment: 2 Pages, Deadline:
5 days
I am delighted with expert work this time because the assignment is written with excellent words and less similarity.
User ID: 7***43 Australia
Statistics
Thesis: 19 Pages, Deadline:
9 days
Assignment was good. and i scored the amount i was looking for. passed all assignments
User ID: 3***26 Male, Maldives
Statistics
Programming: 2.4 Pages, Deadline:
4 days
Perfect score, the assignment was excellently done, great service, the professor, said excellent grade. I will continue using this service for all my …
User ID: 1***17 New York, United States