I'm new in bash scripting and need help with the following please:
The purpose of this homework is to let students write programs in bash scripting language that enable them to manipulate data in a text file similarly to a database table..
Students should understand the table structure and write the programs check_table, row_select and row_delete using bash scripting language.
Table structure A table consists of a text file that contains lines. The first line contains information about the table and each of the rest of lines represents a data row.
The first line structure is as follows:
- table_name is an alphanumeric string not exceeding 16 characters and does not include the column character ‘:’ nor the space character ‘ ‘. It must be the same as the file name.
- number_of_rows is a integer with value less than 1000.
- number_of_fields is a integer with value less than 10.
- filedname is an alphanumeric string not exceeding 16 characters and not including the space ‘ ‘ nor the comma ‘,’ characters.
Each data row consists of a series of fields delimited by the comma character’,’. Each row has exactly the same number of fields as all other fields in the table. A field consists of a string of alphanumeric characters, does not exceed 16 characters and does not contain the space character ‘ ‘ nor the comma character ‘,’.
students_info:3:5:std_1st_name,std_last_name,year_ of_birth,sex,program amer,salim,1990,m,bit samira,rami,1988,f,ise lamia,rida,1990,f,ise
syntax: check_table <table_name>
The program checks the following in order:
- command syntax
- table exists.
- first line syntax is correct.
- tablename and fieldnames all have correct lengths.
- Table has correct number of rows.
- All rows have correct number of fields.
- table is good
- table has a a problem problem description (first problem encountered)
$ check_table students_info table students_info is good $ check_table student_info1 table students_info has at least one problem: Actual number of rows not equal to the one in the file header.
I need some guide about this.
Thanks in advance.