السلام عليكم ورحمة الله أصدقائي الأعضاء أرجو ممن لديه خبرة في برمجة لينوكس ان يساعدني في حل هذه المسائل البرمجية على shell script باستخدام محررات لينوكس
الشكر مقدما لمن يريد المساعدة والأستفادة
أخوكم حسان
هذاه هي المسائل مشكورين :
Students should understand the table structure and write the programs check_table, row_select and row_delete using bash scripting langauge.
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:number_of_rows:number_of_fields:fieldna me1,fieldname2,filedname3 ...etc
- 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 ‘,’.
Example:
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
Programs
1.check_table
syntax: check_table <table_name>
Description:
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.
Output:
- table <tablename> is good
- table <tablename> has a a problem
problem description (first problem encountered)
example:
$ 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.
2. row_select
syntax: row_select <field1>,<filed2>,<field3>... from <tablename> where <fileld> eq <vlaue>
Description:
The command first checks if the syntax is correct, then checks if tablename exist and all fields exist in the table tablename and that the value is less than 16 characters. It exits on the first error occurrence.
After checks, the command lists the count of rows that satisfy the where clause and output the their required fields.
The command assumes that the table structure is good.
Output:
- 1st line: n rows (n is the number of rows that matches the where clause).
- Following lines: field1_value1,field2_value2, ...etc (field values of rows satisfying the where clause).
example:
$ row_select std_1st_name:std_last_name from students_info where program eq ise
2 rows
samira,rami
lamia,rida
3. row_delete
syntax: row_delete from <tablename> where <field> eq <value>
Description
The command first checks if the syntax is correct, then checks if tablename exist and field exists in the table tablename and that the value is less than 16 characters. It exits on the first error occurrence.
After checks, the command lists the count of rows that satisfy the where clause, delete them from the table and modify the table header.
Output:
- n row(s) deleted where n is the number of deleted rows.
example
$ row_delete from students_info where program eq bit
1 row(s) deleted.
المفضلات