Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Unix utilities head and tail output the first and last parts of files respectively. Your assignment is to implement your own version of these

The Unix utilities head and tail output the first and last parts of files respectively. Your assignment is to implement your own version of these utilities in C.

Implement either head or tail, even or odd line listing (your choice).

Note in the comment block how well you completed the task (eg. Works completely; or x and y work, but z does not).

Use getopt to accept the following optional parameters:

{ head | tail } [OPTION ] . . . [ FILE ]

Print the first | last 10 lines of FILE to standard output .

If no FILE read standard input.

Options :

-n K output the first|last K lines

-V Output version info: Your name, email, student number.

-h display all options ( something like this ) and exit

-e|-o print even|odd lines.

The odd and even line printing maybe a little bazaar and generally useless, but it is there to test your programming. If -n 20, then your program should output 20 lines (eg. half of the first|last 40 lines). Number the first line of the file as 1 when calculating odd and even.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions