CSCI 344
grep Problems

Make sure you finish the sed exercises and I've seen your answers before you leave today.  You will not get credit for the sed lab if I don't see your answers today.

Use jaguar's man page to learn about grep

    $ man grep


Problems

Demonstrate how to use grep to solve each of the following:
    1. List all lines in a single file that end with a ;
    2. Print the number of empty lines or lines with only whitespace (spaces and tabs)  in a single file (use only grep for this, don't pipe the output to another filter).
    3. Recursively search files in a directory tree, print all lines that start with a tab (the output will automatically include the directory, the filename and the line for each match).
    4. Recursively search files in a directory tree, print all filenames of files that have lines that contain a tab (the output automatically will contain the directory, filename, and number of matches for that file).
    5. Find all occurrences of your name in a file.  Your pattern must match first last and last, first.  Ignore case.
    6. List all lines in a file that contain an if statement containing a single =.  For example if (a = b).  Do not find lines that contain if statements with a double = (e.g. if (a == b)).  Forgetting the second = is a common mistake for beginning programmers.  There are many different ways to do this.  Try to develop a way that would help beginning programmers.