Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C code to replicate head command in linux In this programming assignment, you will demonstrate your ability to write a basic Unix/Linux program utilizing systems

C code to replicate "head" command in linux

image text in transcribed

In this programming assignment, you will demonstrate your ability to write a basic Unix/Linux program utilizing systems calls by writing a version of the head program, similar to that available on the Unix/Linux system. Program Requirements Your program should implement a subset of the functionality of the head program, as implemented on the Unix/Linux system. The functionality to be implemented is described below Begin by familiarizing yourself with the head program on the Unix/Linux system, both by reading the man pages and by running the command itself. In its simplest form, head prints the first ten lines of each argument file to standard output. If more than one file name is given as an argument, each ten-line output should be preceded by a one-line header giving the name of the corresponding file. head also accepts several command line options, which may be interspersed along with the files to be processed. Your program should also handle the following options n", where N is a positive integer. If specified, the program should print the first N lines "-n of the file, instead of the first ten lines. .c N, where N is a positive integer. If specified, the program should print the first N bytes of the file, independent of the number of lines. Note that several options may be given at once. Run the head program on t he Unix/Linux system to observe the effects. Program NON-Requirements You are only required to implement the features as described above. In particular, note that you are not asked to do any of the following . Handle arguments given to any option without an intervening space (e.g. "-n25"). . Handle negative numeric arguments (e.g. "-n-10"). Handle "as filename. In this programming assignment, you will demonstrate your ability to write a basic Unix/Linux program utilizing systems calls by writing a version of the head program, similar to that available on the Unix/Linux system. Program Requirements Your program should implement a subset of the functionality of the head program, as implemented on the Unix/Linux system. The functionality to be implemented is described below Begin by familiarizing yourself with the head program on the Unix/Linux system, both by reading the man pages and by running the command itself. In its simplest form, head prints the first ten lines of each argument file to standard output. If more than one file name is given as an argument, each ten-line output should be preceded by a one-line header giving the name of the corresponding file. head also accepts several command line options, which may be interspersed along with the files to be processed. Your program should also handle the following options n", where N is a positive integer. If specified, the program should print the first N lines "-n of the file, instead of the first ten lines. .c N, where N is a positive integer. If specified, the program should print the first N bytes of the file, independent of the number of lines. Note that several options may be given at once. Run the head program on t he Unix/Linux system to observe the effects. Program NON-Requirements You are only required to implement the features as described above. In particular, note that you are not asked to do any of the following . Handle arguments given to any option without an intervening space (e.g. "-n25"). . Handle negative numeric arguments (e.g. "-n-10"). Handle "as filename

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago