有没有shell方面的练习题?

有没有shell方面的练习题?

有没有shell方面的练习题?      
自己随便练习就行了      
天拉....谁想做linux shell的练习啊?
找我找我...
我这有一份...正头痛着呢...
如果看到此贴请回复我
或者加我QQ: 39527855      
怎么那个楼主还不在啊???
快来快来 我这有作业给你做啊...      
怎么还是没有人来呢? 唉...      
你这人真的很奇怪, 有问题就发个帖子给大家看看嘛      
好 ...我发...
以下就是我的一个非常大的头痛的问题:


Dominion Consulting in Sydney needs a program to maintain its employee records file, which contains the following information about each employee: telephone number, name, department number, job title, and date of hire. This program should let users add, delete, locate, and display specific employee information. You can meet these needs by creating several UNIX shell scripts.



You start with creating a text file named recordscontaining the following records with fields delimited by colons:



02-95671660:Jones:Sarah:B:45:sales manager:14-12-1995

02-93272658:Smith:John:C:43:technical manager:12-10-1993

02-98781987:Williams:Nick:T:35:computer officer:10-08-1998

02-99893878:Brown:Sarah:B:12:electrician:09-02-1992

02-95673456:Couchavid:A:26:chef:23-04-1994

02-95437869:Anderson:Sarah:K:19:CEO:21-09-1988



You main shell script (must be named menu) will present a menu of operations that a user may choose from. Among other tasks, these operations automate the process of



1. Displaying all current employee records on the screen.

2. Displaying all current employee records (formatted and sorted) on the screen.

3. Displaying only names and phone numbers on the screen.

4. Displaying only names and phone numbers (formatted and sorted) on the screen.

5. Searching for and displaying specific employee record(s).

6. Add new records to the records file.

7. Delete records from the records file.



You could use some simpler combination of some UNIX commands to perform tasks 1, 2, 3, 4, and 5. For tasks 6 and 7, you need to write separate shell scripts (must be named add and delete, respectively), and call these scripts in your main script menu.



You may need to investigate some or all of these UNIX commands: awk, sort, tr, cut, paste, sed, grep搜索. You may also need to investigate some other UNIX commands.



You are strongly recommended to make a directory named kxc254ass1 under your home directory, and use kxc254ass1 as your working directory for this assignment.











      
Your Main Script menu



Your main script menu will produce the following menu of operations that a user may choose from





Employees Info Main Menu

========================



1 - Print All Current Records

2 ? Print All Current Records (formatted)

3 ? Print Names and Phone Numbers

4 ? Print Names and Phone Numbers (formatted)

5 - Search for specific Record(s)

6 - Add New Records

7 ? Delete Records



Q - Quit



Your Selection: (waiting for user input)




? After the user makes a selection and that the selected operation has been completed, the above main menu must be displayed again so that the user can make another selection. You must use a while loop together with a case conditional to implement this. Additionally your script menu must clear the user screen before the main menu is displayed. In all of the following steps, every time the main menu is displayed the user screen has to be cleared first.



? At the beginning of your menu script, you must define three variables which take the values of records, add, and delete, respectively, and use these variables in all statements that refer to the files records, add, and delete. For example, you may define:



record_file=records

add file=add

delete file=delete



and use $record_file in all statements that refer to the file records. One advantage of such practice is that, if at a later time you have to rename the file records, or if it becomes necessary to get your shell script to operate on a different records file, you only need to modify the above one statement instead of modifying all statements that refer to the records file. Define the other two variables like these:



add_file=add

delete_file=delete



? Following the above definitions, your menu script must check to see whether the required files (records, add, and delete) actually exist under the current directory. If any of the files does not exist, your script menu must display the following message and then exit:



Required file theMissingFile does not exist.



For example, if records file does not exist, display “Required file records does not exist.”, and then exit.



? On the above menu (which is waiting for a user selection) if the user accidentally types in a code other than 1, 2, 3, 4, 5, 6, 7, or Q, the message "Invalid code! Press Enter to continue…" must be displayed (make sure that then the cursor stays at the end of this message line instead of the beginning of the next line). After the user presses Enter, the main menu appears again so that the user can make another choice. The user must be allowed to enter either Q or q to terminate.



? On the above menu (which is waiting for a user selection) if the user simply presses the Enter key (instead of typing in a code), the message "Selection not entered. Press Enter to continue…" must be displayed (again make sure that then the cursor stays at the end of this message line instead of the beginning of the next line). After the user presses Enter, the main menu appears again so that the user can make a choice.








      
When the User Selects Option 1 - Print All Current Records



Here is a sample output of your script menu when the user selects 1 on the main menu:



(The main menu here)



Your Selection: 1 (user input)

02-95671660 Jones Sarah B 45 sales manager 14-12-1995

02-93272658 Smith John C 43 technical manager 12-10-1993

02-98781987 Williams Nick T 35 computer officer 10-08-1998

02-99893878 Brown Sarah B 12 electrician 09-02-1992

02-95673456 Couch David A 26 chef 23-04-1994

02-95437869 Anderson Sarah K 19 CEO 21-09-1988



Press Enter to continue... (Waiting here for the user to press Enter. After the user presses Enter, the main menu is displayed again)



(Note the difference between the above output and the content of the records file: all the colons have been replaced by space. You need to find out which Unix command does this.)




When the User Selects Option 2 ? Print All Current Records (formatted)



Here is a sample output of your script menu when the user selects 2 on the main menu:



(The main menu here)



Your Selection: 2 (user input)

Anderson Sarah K 02-95437869 19 CEO 21-09-1988

Brown Sarah B 02-99893878 12 electrician 09-02-1992

Couch David A 02-95673456 26 chef 23-04-1994

Jones Sarah B 02-95671660 45 sales manager 14-12-1995

Smith John C 02-93272658 43 technical manager 12-10-1993

Williams Nick T 02-98781987 35 computer officer 10-08-1998



Press Enter to continue... (Waiting here for the user to press Enter. After the user presses Enter, the main menu is displayed again)



(Note that the above output has been formatted and sorted by family name. Each column must be left justified.)






When the User Selects Option 3 ? Print Names and Phone Numbers



Here is a sample output of your script menu when the user selects 3 on the main menu:





(The main menu here)



Your Selection: 3 (user input)

Jones,Sarah,02-95671660

Smith,John,02-93272658

Williams,Nick,02-98781987

Brown,Sarah,02-99893878

Couch,David,02-95673456

Anderson,Sarah,02-95437869



Press Enter to continue... (Waiting here for the user to press Enter. After the user presses Enter, the main menu is displayed again)



(Note the difference between the above output and the content of the records file. The colons have been replaced by comma. For each entry, only the name and the phone number is displayed)






When the User Selects Option 4 ? Print Names and Phone Numbers (formatted)



Here is a sample output of your script menu when the user selects 4 on the main menu:



(The main menu here)



Your Selection: 4 (user input)

Anderson Sarah 02-95437869

Brown Sarah 02-99893878

Couch David 02-95673456

Jones Sarah 02-95671660

Smith John 02-93272658

Williams Nick 02-98781987



Press Enter to continue... (Waiting here for the user to press Enter. After the user presses Enter, the main menu is displayed again)



(Note that the above output has been formatted and sorted by family name. Each column must be left justified.)






When the User Selects Option 5 - Search for specific Record(s)



Here is a sample output of your script menu when the user selects 5 on the main menu:



(The main menu here)



Your Selection: 5(user input)

Enter keyword: Jones (user input)

02-95671660:Jones:Sarah:M:45:admin assistant:12-12-1990



Press Enter to continue... (Waiting here for the user to press Enter. After the user presses Enter, the main menu is displayed again.)






If the entered keyword does not exist in any record, the following sample output must be produced:





(The main menu here)



Your Selection: 5(user input)

Enter keyword: Monks (user input)

Monks not found



Press Enter to continue... (Waiting here for the user to press Enter. After the user presses Enter, the main menu is displayed again.)






If the user simply presses the Enter key instead of typing in a keyword, the following output must be produced:



(The main menu here)



Your Selection: 5(user input)

Enter keyword: (user simply presses the Enter key without typing in anything)

keyword not entered

Enter keyword: (still wanting for the user to type in something)






? You must allow the user to enter a keyword in both lowercase and uppercase (eg, both JONES and jones generate the same output).





      
没什么难度啊, 费点儿时间而已