CS501

MP1 - Joinin' it


Task

The following are two database files (sfile, pfile). Use Unix utilities to generate a report as shown below.

Contents of "file1": 

S1:Smith:20
S2:Jones:10
S3:Blake:30
S4:Clark:20
S5:Adams:30

Contents of "file2": 
 
S1:5-7:165:20:40K
S2:6-1:150:10:26K
S3:5-9:146:30:35K
S4:5-1:120:20:28K
S5:5-2:180:30:18K

Contents of report: 

 
S#      Name    Height  Weight  Status  ID      Salary
S1      Smith   5-7     165     20      20      40K
S2      Jones   6-1     150     10      10      26K
S3      Blake   5-9     146     30      30      35K
S4      Clark   5-1     120     20      20      28K
S5      Adams   5-2     180     30      30      18K

What You Do

  1. Create the files file1 and file2 on your Unix account.
  2. Read the join man pages and figure out how to slap these guys together.
  3. Place the necessary commands in a shell script. Call it joinem.
  4. Turn in a listing of joinem with your name, MP1 and CS501 on the top.

Hints

  1. See the man pages for join (click here if you cannot get the man pages to work)..
  2. Create the joinem file on your PC and ftp the file to your account (or use vi or pico).
  3. Pipe (|) the output from the join command into "tr ':' '\011'"
  4. After you create the script file, make sure it is executable (chmod 755 filename).


* from here.