Sonoma State University
Department of Computer Science
CS-210: Introduction to Unix
Exercise 13: Prepare for final exam

Objective:

To prepare for the final exam through a series of exercises similar to what you will see on the final exam.

Questions

  1. Download fruit_prices.csv (comma separated values) to your computer. Then transfer this file (secure FTP) to your home directory on Blue. Please view fruit_prices.csv to see how the data is organized as comma separated values the answer the following questions:
    1. Write the Unix command to list out the names of all fruit in "Canned" form (form field).
    2. Write the Unix command to list out the names of all fruit sorted by fruit field (list ascending order A to Z).
    3. Write the Unix command to list out all fruit categorized as "Fresh" (form field) with a price greater than $3.00 (retail price field).
  2. The Blue Unix server contains a list of dictionary words located in /usr/share/dict/words. Use this dictionary to answer the following question. Write a Unix command to list all seven letter words in the dictionary with the fourth letter being "z" and the seventh letter being "c". Your Unix command should sort the output list of words in ascending alphabetical order.
  3. The file secret_message.txt contains a secret message. Write a Unix command to decode the message in secret_message.txt. The file uses a simple encoding technique based on the following table of data:
    INPUT LETTER OUTPUT LETTER
    A H
    B Z
    C J
    D K
    E W
    F P
    G O
    H A
    I L
    J C
    K D
    L I
    M N
    N M
    O G
    P F
    Q V
    R X
    S U
    T Y
    U S
    V Q
    W E
    X R
    Y T
    Z B
  4. Please download the text files, customers.txt and purchases.txt. These files contain comma separated values. The customers.txt file contains a customer ID number (a unique number) and the customer’s name. The purchases.txt file contains a customer ID (a unique number) and the purchased item.
    1. Using the Unix join command, merge the contents of customers.txt and purchases.txt based on the first field (customer ID).
    2. Using the purchases.txt file, write a Unix command to count the number of times each product was purchased then order the items by least purchased to most purchased. Your output should look like this without the headers or the table border:
      Quantity Product
      1 blueberries
      1 lettuce
      1 potato chips
      1 potato salad
      1 sweet potato
      2 acorn squash
      2 bananas
      3 strawberries
      3 wheat bread
  5. The file electric_vehicle_charging_station_addresses.csv Download electric_vehicle_charging_station_addresses.csv contains the addresses of electric vehicle charging stations in selected cities within Sonoma county. The file is text-based and formatted using comma separated values: (i.e. street, city, state, zip). The file contains one flaw: the state field contains variations on California (e.g. CA, Cal., Calif., etc.). Using sed and regular expressions, write a Unix command to substitute "California" for each variation you see in the state field when referring to California. Your Unix command should redirect its output to a file named "STANDARDIZED-electric_vehicle_charging_station_addresses.csv". The variations on California include: "CA", "CA.", "Ca", "Ca.", "ca", "ca.", "CAL", "Cal.", "cal", "cal.", "CALIF", "CALIF.", and "CALIFORNIA".

Submission Instructions:

Please submit your answers to the questions above to Canvas.

Exercise 13 Rubric

CRITERIA RATINGS POINTS
Question 1: Proficient
3 points

Student submitted a Unix command to list the names of all fruit in "Canned" form. Student submitted a second Unix command to list out the names of all fruit sorted on the fruit field in ascending alphabetical order. Student submitted a third Unix command to list out all fruit categorized as "Fresh" in the form field with a price greater than $3.00 in the retail price field.
Satisfactory
2.1 points

Student submitted a Unix command to list the names of all fruit in "Canned" form. Student submitted a second Unix command to list out the names of all fruit sorted on the fruit field. Student submitted a third Unix command to list out all fruit categorized as "Fresh". There was one syntax or logical error in one of the three Unix commands which prevented that command from displaying the correct results.
Needs Improvement
1.8 points

Students submitted at least two Unix commands. The Unix commands contain two or three syntax or logical errors which prevent the commands from displaying the correct output.
Below Expectation
0 points

No answer submitted.
3 points
Question 2: Proficient
1 point

Student's solution searches the built-in Unix dictionary on Blue (located at /usr/share/dict/words) to list all seven letter words with the fourth letter being "z" and the seventh letter being "c". The student's solution sorts the output list of words in ascending alphabetical order.
Satisfactory
0.7 points

Student's solution searches the built-in Unix dictionary on Blue (located at /usr/share/dict/words) but there is one syntax or logical error which prevents the student's solution from outputting the correct results.
Needs Improvement
0.3 points

Student's solution searches the built-in Unix dictionary on Blue (located at /usr/share/dict/words) but there are two or three syntax or logical errors which prevents the student's solution from outputting the correct results.
Below Expectation
0 points

No answer submitted.
1 points
Question 3: Proficient
1 point

Student's solution uses a Unix command to properly decode the secret message.
Satisfactory
0.7 points

Student's solution attempts to decode the secret message but there is one syntax or logical error which prevents the solution from properly decoding the secret message.
Needs Improvement
0.3 points

Student's solution attempts to decode the secret message but there are two or three syntax or logical errors which prevents the solution from properly decoding the secret message.
Below Expectation
0 points

No answer submitted.
1 points
Question 4: Proficient
2 points

Student's solution uses the Unix join command to merge the contents of the files "customers.txt" and "purchases.txt" based on the customer ID field. Student submitted a another Unix command using the "purchases.txt" file to count the number of times each product was purchased. The items are listed from least-purchased to most-purchased order.
Satisfactory
1.4 points

Student's solution uses the Unix join command to merge the contents of the files "customers.txt" and "purchases.txt". Student submitted another Unix command using the "purchases.txt" file to count the number of times each product was purchased. There is one syntax error or logical error which prevents the Unix join command from working properly; OR there is one syntax error or logical error which prevents the second Unix command from properly counting the number of times each product was purchased.
Needs Improvement
0.6 points

Student solution contains two or three syntax or logical errors which prevents one or both of the Unix commands from working properly.
Below Expectation
0 points

No answer submitted.
2 points
Question 5: Proficient
1 point

Student's solution uses the Unix sed command along with a regular expression to replace the following variations with "California" in the state field: "CA", "CA.", "Ca", "Ca.", "ca", "ca.", "CAL", "Cal.", "cal", "cal.", "CALIF", "CALIF.", and "CALIFORNIA". Student's solution saves the output from the sed command to a file named "STANDARDIZED-electric_vehicle_charging_station_addresses.csv"
Satisfactory
0.7 points

Student submitted a Unix sed command with a regular expresion. The student's solution contains one logical or syntax error which prevents the sed command from working as expected.
Needs Improvement
0.3 points

Student submitted a Unix sed command with a regular expresion. The student's solution contains two or three logical or syntax errors which prevent the sed command from working as expected.
Below Expectation
0 points

No answer submitted.
1 points
Total points: 8