grep, sort, and uniq

Assignment 3

For the following questions use grep, sort, and uniq. When redirecting (>) to a file be sure to use a different name! The file dist.male.first and dist female.first contains a list of male and female first names and their ranking from the 1990 US Census. The file names contains a fictitious list of first and last names. Show only the commandline to produce the required results. (All problems can be solved with one commandline but you can use several lines if you can't get it to work with one.)

  1. Find all names in the file dist.male.first that begin with 'JEFF'.
  2. Find all names in the file dist.male.first that end in 'SON'.
  3. Find all names in the file dist.male.first that end in 'SON' and sort them alphabetically.
  4. Find which names are in both the male and female files. (You will need to use cut or sed to get just the names from the files.)
  5. Combine the files of male and female first names and sort them by rank (column 4).
  6. Combine the files of male and female first names and sort alphabetically and remove duplication.
  7. Display the female names that start with L.
  8. Starting with the file 'names' create a list of the first names in alphabetical order with the number of their rank by occurrence before each name. (Hint: nl will add line numbers to the output.) (3 marks)