1.

Solve : Writing a executable script in UNIX?

Answer» Hello,

Can someone please help me with the below?


Create an executable script file called “newname” that will perform the followings:

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
“Name of file you want to rename.” Use the “\c” escape character.
“New name of file” Use the “\c” escape character.
“File Exist” to avoid overriding a file.
“File $oldname CHANGED to $newname”
“Do you want to rename another file?” If the user SELECTSYES” the system should refresh the screen and if the user selects “no” the system should exit to the prompt sign.


I am stuck on how to get input from the user and how to check if it is an EXISTING file. Also, I am unclear with using the "\c" escape character. Please help or direct me somewhere I can get help. Thanks!

PS..

This is what I have so far. I'm using the vi editor. I'm not even sure if I'm on the right track

vi nename [ENTER]

#!/bin/sh
echo "Please eneter the name of the file you want to rename"




Discussion

No Comment Found