Project: lb_head

Node.js·2 min read·Apr 17, 2025

In Unix, the head utility is used to display the first N bytes or lines of each of the specified files.

The objective of this project is to write a Node.js command-line script that partially reimplements the head utility.

General instructions

Here are the general instructions to complete this project:

  1. The script must be named lb_head.js.
  2. The script must be written in Node.js.

Flags and arguments

The script must have the following synopsis:

$ node lb_head.js [-h] [-n count | -c bytes] file ...

Where:

  • -h, --help is an optional flag used to output the script synopsis.
  • -n, --lines is an optional flag used to print count lines of each file. Defaults to 10 if omitted.
  • -c, --bytes is an optional flag used to print bytes bytes of each file.
  • file ... is a list of file paths used as input.