InterviewSolution
Saved Bookmarks
| 1. |
Solve : unix script writing? |
|
Answer» I need help writing this script. Here is the script and my answer. Can SOMEONE help me please. This is my first script. Create an executable script file called “newname” that will perform the followings: 1.Rename a file upon the user’s request. If the file exists, prompt the user for confirmation before renaming the file. The screen should prompt the user for a.“Name of file you want to rename.” Use the “\c” escape character. b.“New name of file” Use the “\c” escape character. c.“File Exist” to AVOID overriding a file. d.“File $oldname changed to $newname” e.“Do you want to rename another file?” If the user selects “yes” the system should refresh the screen and if the user selects “no” the system should exit to the prompt sign. f.Refresh the screen to go back to the menu until the user selects the exit option This is what I wrote rm -i Echo "\c" Read a file to rename If file do not exist Then Echo"\c"Rename the file Otherwise EchoAsk if the user wants to override file EchoRead the user's choice (y/n) If the answer is yes (y) Then Echo"Rename the file" Otherwise EchoDisplay message ("File Exist") Fi Refresh the screen Exit You have made a good START, you have written out the logic of the script. Now you need to research the shell commands and put them in the correct PLACES in your script, then run it and edit it until it does what you want. |
|