Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started