[SOLVED] CSCI1730 - Project 3 – Unix Utility

30.00 $

Category:

Description

5/5 - (3 votes)

For this project, you are tasked with implementing a collection of basic Unix utilities using low-level system calls. Not all utilities are the same difficulty. Please manage your time wisely.

Here is the list of utilities that you must implement:

  1. ./head [ -c number | -n number] [files…]

./tail [ -c number | -n number] [files…]

  • points) The head and tail utilities should copy their input files to the standard output, ending or starting the output for each file at a designated point, respectively. Copying must end/begin at the point in each input file indicated by the -c number or -n number The option-argument number is counted in units of lines or bytes, according to the options -n and -c, respectively. Both line and byte counts start from 1. If no options are specified, act as if -n 10 had been specified. If no files operand is specified, or when one of the files is -, then standard input is assumed.

-n number: The first (head) or last (tail) number lines of each input file to be copied to standard output. The application must ensure that the number option-argument is a positive decimal integer. When a file contains less than number lines, it must be copied to standard output in its entirety. This should not be an error.

-c number: Output the first (head) or last (tail) number of bytes. A positive decimal integer as well.

  1. ./wc [-clw] [files…]
    • points) The wc utility should read one or more input files and, by default, write the number of newlines, words, and bytes, in that order, contained in each input file to the standard output (in other words, the default behavior matches having the options -clw). The utility should also write a total count for all named files, if more than one input file is specified. The wc utility should consider a word to be a non-zero-length string of characters delimited by whitespace characters. Your program should be able to handle any combinations of the -c, -l and -w, in any order (e.g, -wl, -c, etc.). If no files operand is specified, or when one of the files is -, then standard input is assumed.

-c: Write to the standard output the number of bytes in each input file.

-l: Write to the standard output the number of newlines in each input file.

-w: Write to the standard output the number of words in each input file.

  1. ./true

./false

(10 points) The true utility shall return with exit code EXIT SUCCESS. The false utility shall return with exit code EXIT FAILURE. 4. ./env

(10 points) The env utility prints all of the currently set environmental variables to standard output