Main Course Webpage

Course Slack Page

In-Class Lab 9: Filters

Recursively copy the directory Filters from beneath /pub/cs/grwoo/Filters to your directory. Then connect to Filters

Part One

Review the format of the file licenses using more. This file has two fields, license and state, separated by a tab. execute commands to do the following tasks and answer the questions:

Note: you will have to be able to use a sort key with a character offset for this lab. Review the notes for how to do that

  1. how many licenses are California licenses? Answer: ____

  2. sort and display licenses sorted by license.

  3. sort licenses by the alphabetic portion of the license. Write the command you used: ____

  4. sort the licenses by state, then, within each state, sort by the alphabetic portion of the license.

  5. How many license/state combinations are duplicates? Answer: ____ (i.e., how many license numbers appear with multiple states)

  6. There are obviously duplicate states. How many states have licenses in the file? ____

  7. Disregarding the state, how many duplicate license numbers are there? Answer: ____ (i.e. how many license numbers appear with multiple states)

  8. Create a file named Nevada that contains a list of Nevada licenses, one per line. The only field on each line should be the license. The list should be sorted numerically in reverse order by the last 3 digits of the license.

  9. Shirley witnessed a hit and run. She remembers the car had California plates, that hte license started with a 2 and had the number 10 in it. Write out the possibilities for what the license plate was.

Part Two

Review the format of the file groups using more. This is an abbreviated version of the standard Unix file /etc/group. Each line in the file has the following format:

gname::gid:members

Execute commands to do the following tasks and answer the questions:

  1. sort the file groups by the gid field

  2. create a new file grp that consists of the gid and the gname field, in that order, separated by a #. The file should be sorted by gid.

  3. output a single line that contains the members of the group with gid 3012. The members should be on a single line, separated from each other with a space. Write out this command

  4. What is the smallest gid in the file?

For solutions and hints, refer to Greg Boyd's original assignment

Submitting Your Homework Assignment

Submit your answers as an ordinary text file on Canvas