Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can I mimic the head Unix command in my own program? The head utility shall copy its input files to the standard output, ending

How can I mimic the head Unix command in my own program?

The head utility shall copy its input files to the standard output, ending the output for each file at a designated point. Copying shall end at the point in each input file indicated by the -n number option. The optionargument number shall be counted in units of lines. If no file operand is specified, or when file is -, then standard input is assumed. -n number: The first number lines of each input file shall be copied to standard output. The application shall ensure that the number option-argument is a positive decimal integer. When a file contains less than number lines, it shall be copied to standard output in its entirety. This shall not be an error. If no options are specified, head shall act as if -n 10 had been specified. I need to use low-level io, such as read() and write(). I need to know the logic behind how to do this with varying buffersizes.

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

Step: 3

blur-text-image

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions