Sponsored Content
Top Forums Shell Programming and Scripting Post Shell programming: Question about source a file and read data from the file Post 302130301 by ccwq on Saturday 4th of August 2007 10:25:18 PM
Old 08-04-2007
Something about my assignment

1. Student Database
In this assignment you will design a simple file based database. All the files are in
the simplest form of CSV (Comma Separated Values) where every pair of adjacent fields
are sperated by a comma and the fields do not contain any commas, not even escaped.
Every line contains a single record and every record contains several fields. A set of files
will be provided and your code will be tested against these files as well as a few more that
you will not know in advance. You can use either ash or bash. You can use any stan-
dard utility we discussed in class but you cannot write a program in any other program-
ming environment. Your programs do not create any file (other than a possible temporary
file in the /tmp/ directory) anywhere and print everything in the standard output.
2. Files in the Database
The database will have three types of files. The first, of which there is only one
instance, is the Accounts file. It contains records that have three fields. The first field is
an account number, the second is the last name of the student and the third is the first
name. Please note that some students have names with non letter characters like space,
dot or hyphen.
The second type of file is the enrollemnt file, one for each course and they are
named CSExxxx where the x's are digits, very much like our own courses. They contain
a series of records, each one with a single field, an account number. If a student has regis-
tered for a course, his account number appears in the corresponding file.
The third type of file is the marks file, the one submitted by course instructors one
for each course, are named MARKSxxxx and are associated with the corresponding
CSExxxx course. The files contain several records, one for each student in the course
that received a mark. Every record contains two fields: the account number and the stu-
dent mark from 0 to 100. If a student is in the CSExxxx but has no record in the corre-
sponding MARKSxxxx gets a zero. If the file CSExxxx exists but the file MARKSxxxx
does not, all students get IP (that is In Progress).
There is one more file in the database and this resides in the home directory of the
user, is named .std_dbrc and contains exactly one statement
STD_DBROOT=<blahblah>
and this is used by your scripts to find where is the directory of the database.
1
3. Scripts
You have to write four scripts. All scripts follow the specification regarding the
startup file .std_dbrc and provide reasonable error reporting. All missing files should
be reported. The output should be exactly as in the specification without anything extra.
They will be tested both by hand and by automarking.
3.1. Find the Name
Write a script std_db_acc2name that given the account number of a student as a
command line argument returns the name as comma separated values.
3.2. Find the Courses
Write a script std_db_acc2courses that given the account number of a student
as a command line argument returns the comma separated list of courses the student is
registered.
3.3. Find the Marks
Write a script std_db_acc2marks that given the account number of a student as
a command line argument returns the comma separated list of courses and marks the stu-
dent has received.
3.4. Create the Table
Write a script std_db_acc2table that returns a CSV file with the following
structure. All records in the file contain the same number of fields. The first record, is the
header record and its first field is just the string “Std. Name”. The rest of the fields are the
4 digit codes for the all the courses. All the subsequent records have as their first field the
student name (first name first, then last name and no comma) and the rest of the fields are
the corresponding marks, blank if the student is not registered in the course and the regu-
lar mark or IP if the student is registered. Students that are registered in no course do not
have a record in this table.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

To Read a text file using shell Programming

Hello! I need to read a text file containing certains rows and columns!The following is a sample file with only three rows! 01:41:30:00:05:51 OFF 48506649K 5769415 63494357K 01:41:30:00:05:65 ON 4493546K 27266552 5880264K 01:41:30:00:05:78 OFF 614556K 89121 47291K... (1 Reply)
Discussion started by: sandytul
1 Replies

2. Programming

How to read specific lines in a bulk file using C file Programming

Please Help me I have a Bulk file containing Hex data I want to read specific lines from that bulk file by ID number. example ID DATE Time data 14 2005/09/28 07:40:08.546 0 5 078B1C 01916C 0FE59C 004B54 0A9670 0D04ED 05B6B4 0E2223... (10 Replies)
Discussion started by: rajan_ka1
10 Replies

3. Shell Programming and Scripting

Awk/shell question: Read from file and assign to variables.

Is anyone able to help with writing a program that will do the following: 1. Read the contents of a file, line by line, and on each line, assign each of the two columns to a shell variable. 2. perform an action on the variables 3. Read the next line. Here is what I've gotten so far. ... (3 Replies)
Discussion started by: akbar
3 Replies

4. Shell Programming and Scripting

How to read the data from the text file in shell script?

I am having one text file and i need to read that data from my shell script. I will expain you the scenario: Script look like: For name type 1: For age type 2: For Salary type3: echo "Enter the input:" read the data if input is 1 then go to the Text file and print the... (2 Replies)
Discussion started by: dineshmurs
2 Replies

5. Shell Programming and Scripting

Read data from .csv file through shell script & modify

I need to read data from a file called "test.csv" through shell script where the file contains values like name,price,descriptor etc. There are rows where descriptor (& in some rows name) are written as string & other characters like "car_+" OR "bike*" etc where it should contains strings like... (3 Replies)
Discussion started by: raj100
3 Replies

6. UNIX for Dummies Questions & Answers

Mapping a data in a file and delete line in source file if data does not exist.

Hi Guys, Please help me with my problem here: I have a source file: 1212 23232 343434 ASAS1 4 3212 23232 343434 ASAS2 4 3234 23232 343434 QWQW1 4 1134 23232 343434 QWQW2 4 3212 23232 343434 QWQW3 4 and a mapping... (4 Replies)
Discussion started by: kokoro
4 Replies

7. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

8. UNIX for Beginners Questions & Answers

Shell - Read a text file with two words and extract data

hi I made this simple script to extract data and pretty much is a list and would like to extract data of two words separated by commas and I would like to make a new text file that would list these extracted data into a list and each in a new line. Example that worked for me with text file... (5 Replies)
Discussion started by: dandaryll
5 Replies

9. Shell Programming and Scripting

Read csv file, convert the data and make one text file in UNIX shell scripting

I have input data looks like this which is a part of a csv file 7,1265,76548,"0102:04" 8,1266,76545,"0112:04" I need to make the output data should look like this and the output data will be part of text file: 7|1265000 |7654899 |A| 8|12660000 |76545999 |B| The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies

10. Shell Programming and Scripting

How to get the shell script to read the .txt file as an input/data?

i have written my shell script in notepad however i am struggling to pass the data file to be read to the script the data file is of .txt format. My target is to run the shell script from the terminal and pass 3 arguments e.g. polg@DESKTOP-BVPDC5C:~/CS1420/coursework$ bash valsplit.sh input.txt... (11 Replies)
Discussion started by: Gurdza32
11 Replies
All times are GMT -4. The time now is 03:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy