Question: Homework must be done in C. Read the man page for the head system command : man head (https://linux.die.net/man/1/head) Then, write your own version of

Homework must be done in C.

Read the man page for the head system command : man head (https://linux.die.net/man/1/head)

Then, write your own version of the head command according to the following pseudo man page:

NAME:

head - output the first part of files.

SYNOPSIS:

head [OPTION] [FILE]

DESCRIPTION:

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

-nK

Print the first K lines of the file instead of 10.

EXAMPLES:

head prints the synopsis message
head file.txt prints the first 10 lines of file.txt, or all lines if fewer than 10.
head -n5 file.txt prints the first 5 lines of file.txt, or all lines if fewer than 5.

NOTES:

o When interacting with the file, you must use some combination of one or more the following Unix system calls: open, read, write, lseek, close, creat.

o The program does not prompt the user in any way.

o You may not use any C++ specific code.

HINTS:

o Any line will end with the new line character: .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!