CS3157
Fall 2002
Homework #4
due Fri Nov 8, by 6AM (electronically)

goal.
The goal of this assignment is to practice using shell scripts and Perl.

This assignment is worth 10 points (out of 110 this semester). Distribution of points is indicated below.

task.
You will need to write 5 shell scripts and and one Perl script in order to manipulate your data file. For the purpose of this assignment, you will assume that you have a text data file that is formatted as follows:

Here is a sample data file:
yaddi 3 5 9
suzanne 9 23 1 5 7
jennifer 1 2 3 6
alex 9 8 3 5
simon
There are five users. The first user, "yaddi", has played 3 games. The last user, "simon", has not played any games.
You can download a copy of the data file by right-clicking here.

scripts.
You need to write the following scripts to manipulate this file.
Make sure you name the scripts as indicated below!!!

  1. display.sh (1 point)
    This script is used to display the entire contents of the data file. It is run as follows with no arguments:
    unix$ display.sh
    alex 9 8 3 5
    jennifer 1 2 3 6
    simon
    suzanne 9 23 1 5 7
    yaddi 3 5 9
    unix$
    
  2. find.sh (1.5 points)
    This script is used to display the scores for a given user. Assume that the given user's name is entered as the first and only argument to the script. Here's a sample run:
    unix$ find.sh yaddi
    yaddi 3 5 9
    unix$
    
  3. findgame.sh (2 points)
    This script is used to display the scores for a given user from a given game. Assume that the given user's name is entered as the first argument and the game number is the second argument to the script. Here's a sample run:
    unix$ findgame.sh yaddi 2
    5
    unix$
    
  4. create.sh (2 points)
    This script is used to add a new user to the users data file. Assume that the name of the new user is the first and only argument to the script. Here's a sample run:
    unix$ create.sh sylie
    unix$ display.sh
    alex 9 8 3 5
    jennifer 1 2 3 6
    simon
    suzanne 9 23 1 5 7
    sylie
    yaddi 3 5 9
    unix$
    
  5. delete.sh (2 points)
    This script is used to delete a user from the users data file. Assume that the name of the user to delete is the first and only argument to the script. Here's a sample run:
    unix$ delete.sh sylie
    unix$ display.sh
    alex 9 8 3 5
    jennifer 1 2 3 6
    simon
    suzanne 9 23 1 5 7
    yaddi 3 5 9
    unix$
    
  6. update.pl (2 points)
    This Perl script is used to update a user's row in the users data file. Assume that the name of the user to update is the first argument to the script and the second argument is a new game score to add at the end of the user's row. Here's a sample run:
    unix$ update.pl simon 3
    unix$ display.sh
    alex 9 8 3 5
    jennifer 1 2 3 6
    simon 3
    suzanne 9 23 1 5 7
    yaddi 3 5 9
    unix$
    

submit.(0.5 points)
You need to submit your program in ONE way: ELECTRONICALLY ONLY. There is no partial credit here -- if you don't follow the submission instructions, you lose all the points for this section.