tailieunhanh - Unix Shell Programming Third Edition phần 6

Điều gì sẽ xảy ra mycp nếu một hoặc nhiều các tập tin được sao chép không tồn tại? Bạn có thể thực hiện bất kỳ đề xuất để xử lý tình huống tốt hơn? Điều gì sẽ xảy ra để mycp nếu một trong các tên tập tin có chứa một nhân vật có một ý nghĩa đặc biệt với vỏ như; | do printf 12d 12d n number1 number2 done cat data 1234 7960 593 -595 395 304 3234 999 -394 -493 align data 1234 7960 593 -595 395 304 3234 999 -394 -493 In Chapters 12 14 and 15 you ll see more uses for printf. But first try your hand at the following exercises. Team LĨĐ PREVIOUS NEXT Team LiB PREVIOUS NEXT Exercises 1 What happens to mycp if one or more of the files to be copied doesn t exist Can you make any suggestions to better handle the situation 2 What happens to mycp if one of the filenames contains a character that has a special meaning to the shell such as or 3 Write a program called mymv that does with the mv command what mycp does with the cp command. How many changes did you have to make to mycp to produce this new program 4 Modify mycp to prompt for arguments if none are supplied. A typical execution of the modified version should look like this mycp Source file name voucher Destination file name Make sure that the program allows one or both of the files to be specified with filename substitution characters. 5 Add a -n option to mycp that suppresses the normal check for the existence of the destination files. 6 Modify mycp to use sed instead of the while loop to process the arguments typed on the command line. 7 Modify the rem program used by rolo so that if multiple entries are found the program will prompt the user for the entry to be removed. Here s a sample session rolo Please select one of the above 1-3 3 Enter name to be removed Susan More than one match please select the one to remove Susan Goldberg Remove y n n Susan Topple Remove y n y 8 Modify rolo so that the menu is redisplayed after each selection is made and processed. To allow the user to get out of this add another selection to the menu to exit from the program. 9 What happens to the rolo program if just an Enter is given as the name for the add look up or remove options 10 Modify lu to use printf to print the name and phone number so that they line up in columns for names .