有没有shell方面的练习题?

Your Script add



Your script add is activated when the user selects 6 on the main menu. Here is a sample output of add:

(The main menu here)



Your Selection: 6(user input)



(Clear the user screen first)



Employee Info Additions

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

Enter the following details of the new employee:

Phone Number

Last Name

First Name

Middle Init

Dept #

Job Title

Date Hired



Phone Number (xx-xxxxxxxx): 02-90807986 (user input)



(Your script must force the user to enter a valid phone number according to the specified format. Your script must be able to verify the format of the user input.



If the user simply presses the Enter key, the following must be produced:

Phone Number (xx-xxxxxxxx): (user simply presses the Enter key)

Phone number not entered

Phone Number (xx-xxxxxxxx): (still waiting for the user to enter a valid phone number)



If the user enters an invalid phone number or a number in the wrong format, the following must be produced:

Phone Number (xx-xxxxxxxx): abc123 (user input)

Invalid phone number

Phone Number (xx-xxxxxxxx): (still waiting for the user to enter a valid phone number)

An example of a valid phone number (including its area code) is 02-95671600. Examples of invalid phone numbers are 0363243416 (format incorrect), 1099887766, 1299998877, etc. Valid area codes are 02, 03, 04, 05, 06, 07, 08. The first digit of a phone number (not including the area code) can be any digit between 1 and 9 (inclusive). The other 7 digits of a phone number (not including the area code) can be any digit between 0 and 9 (inclusive).)



Last Name: Warren (user input)



(A valid last name can contain only alphabets and spaces. Similar to what’s described above, if the user enters an invalid last name, display the message Last name can contain only alphabets and spaces and prompt the user to enter a last name again. If the user simply presses the Enter key without typing in anything, display the message Last name not entered and prompt the user to enter a last name again.)



First Name: Todd (user input)



(A valid first name can contain only alphabets and spaces. Similarly, if the user enters an invalid first name, display the message First name can contain only alphabets and spaces and prompt the user to enter a first name again. If the user simply presses the Enter key without typing in anything, display the message First name not entered and prompt the user to enter a first name again.)



Middle Init: L (user input)



(Valid middle initials can contain only alphabets and spaces. Similarly, if the user enters invalid middle initials, display the message Middle Init can contain only alphabets and spaces and prompt the user to enter middle initials again. If the user simply presses the Enter key without typing in anything, display the message Middle Init not entered and prompt the user to enter middle initials again.)



Dept #: 20 (user input)



(A valid Dept # can contain only digits with no spaces. Similarly, if the user enters an invalid Dept #, display the message Dept # can contain only digits with no spaces and prompt the user to enter a Dept # again. If the user simply presses the Enter key without typing in anything, display the message Dept # not entered and prompt the user to enter a Dept # again.)



Job Title: engineer (user input)



(A valid job title can contain only alphabets and spaces. Similarly, if the user enters an invalid job title, display the message Job title can contain only alphabets and spaces and prompt the user to enter a job title again. If the user simply presses the Enter key without typing in anything, display the message Job title not entered and prompt the user to enter a job title again.)



Date Hired (dd-mm-yyyy): 21-02-1996 (user input)



(Your script must force the user to enter a valid date according to the specified format. Your script must be able to verify the format of the user input.



For simplicity, assume there are 31 days in every month. Valid years are defined as between 1000 and 9999 (inclusive).



If the user enters an invalid date or a valid date in the wrong format, display the message Invalid Date Hired and prompt the user to enter a date again. If the user simply presses the Enter key without typing in anything, display the message Date hired not entered and prompt the user to enter a date again.)



Record Saved



(This message is displayed only after this new record has been successfully added to the records file. This message should not be displayed if this new record has not been successfully added. In the latter case, the UNIX command for appending contents to an existing file will display a standard error message.)



Add another? (y)es or (n)o: y (user input)

(The above procedure - starting from “Clear the user screen first” - is then repeated)




However, if the user enters n, then add is exited and the main menu appears again, so that the user can make another selection (for example, now the user might wish to view the content of the records file so as to make sure that the new record has actually been added into it).



If the user accidentally types in a code other than y or n, add is exited and the main menu appears.



? At the beginning of your add script, you must define a variable that takes the value of records, and use this variable in all statements that refer to the file records.



? Add three new records made up by you to the records file after all your shell programs have been completed.




Your Script delete



Your script delete is activated when the user selects 7 on the main menu. Here is a sample output of delete:



(The main menu here)



Your Selection: 7(user input)



(Clear the user screen first)



Delete Employee Record



Enter a phone number (xxxxxxxx): 95671660 (user input)

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



(Your script must force the user to enter a valid phone number without the area code and the “-“ symbol. If the user enters an invalid phone number, display the message Invalid phone number and prompt the user to enter a phone number again. If the user simply presses the Enter key without typing in anything, display the message Phone number not entered and prompt the user to enter a phone number again.)



Confirm deletion: (y)es or (n)o: y (user input)



Record deleted. (This message is displayed only after this record has been successfully deleted from the records file. This message should not be displayed if this record has not been successfully deleted. In the latter case, the UNIX system will display a standard error message.)



(If the user enters nor a letter other than y or n, then delete is exited and the main menu appears. This will guarantee that the user has to press y to delete a record.)



Delete another? (y)es or (n)o: y (user input)



(The above procedure - starting from “Clear the user screen first” - is then repeated)



(If the user enters nor a letter other than y or n, then delete is exited and the main menu appears.)





However, if no record has been found to contain the entered phone number, then the following must be produced:



Delete Employee Record



Enter a phone number (xxxxxxxx): 55555555 (user input)

55555555 not found



Press Enter to continue ...

(Make sure that then the cursor stays at the end of this message line. After the user presses Enter, the main menu appears.)






? At the beginning of your delete script, you must define a variable that takes the value of records, and use this variable in all statements that refer to the file records.





For All Your Scripts



You must include your name, UTAS student ID, and a brief introduction of what the script does in all your shell scripts. You also need to make your scripts run on the Bourne shell, regardless of which shell the user of your scripts is currently on. Use “\n” where appropriate to make the output of your scripts more readable. Script structure and layout also need to be considered.





Submitting Your Assignment



Submit a hard copy (paper version) AND an electronic copy of your KXC254 assignment one.



You must submit a hard copy (together with a signed cover sheet,stapled) and an electronic copy of the following four files (three shell scripts and one text file): menu, add, delete, records      
哀... 费时间就算了
问题是我不会...
想费时间都不行...
终于发完了...呼...      
斑竹有兴趣吗?还是这个楼主有兴趣...
只是人都没有上线哦...      
发完了 也没有人理...
555......      
[quote=fzheng_1882]只是人都没有上线哦[/quote]
你以为这是 QQ 啊?

这么大的题目, 没时间做, 不过, 如果你付费的话倒是可以考虑

哪儿搞的这个题目? 面试题? 老板给的任务? 自娱自乐?

No pains, no gains. 天上不会掉陷饼的, 努力吧!      
唉... 国外老师布置的作业...作业...
我才没有兴趣在这方面自娱自乐哦...      
人都不见了。。。      
我最近下载了sed和awk的资料,正在学习,所以没有上网,请各位多多包涵。      
那你现在有兴趣练习一份SHELL作业吗      
抱歉,我还需要学习才能真正使用shell.