Lab 6: Fgrep

Introduction

In this lab, you'll be writing the C code for fgrep, a simple command that searches one or more files for a given string.

Starter Code and Instructions

Starter code

The starter code for this lab is already available on the server in the directory /cs/cs105/labs/lab6-fgrep. The first step is to get your own copy of the code to work on. After logging into wilkes, run the following commands:

mkdir -p ~/cs105
cd ~/cs105
cp -ai /cs/cs105/labs/lab6-fgrep .
cd lab6-fgrep

Recall that this will cd into your cs105 working directory, copy the starter code into a new directory called lab6-fgrep and cd into that directory. Note that you'll be writing your implementation in fgrep.c, which is mostly blank.

Example files

If you run ls, you'll see there is a subdirectory with a couple demo programs (with a Makefile to make them). As described in the writeup linked below,

Testing files

Along with the starter fgrep.c and the examples, you'll also see some testing files:

Fgrep lab handout

Finally, here is the handout with the instructions for implementing fgrep.

Also, note that we introduced the Fgrep lab in lecture 20.

Due Date and Submission

Due: Friday December 4th, 1:15pm.

As described in the writeup, you should submit fgrep.c using the following command:

cs105submit -a 06 fgrep.c