Computing.Net > Forums > Programming > a question about bash shell script

a question about bash shell script

Reply to Message Icon

Original Message
Name: stewchicken
Date: November 12, 2001 at 13:45:34 Pacific
Subject: a question about bash shell script
Comment:

Dear All

I hava a questions as following

Write a shell script program called 'safecopy' that takes two filenames
(file1 and file2) as arguments. If file2 exists and file2 is a file that can
be written to, then the user should be warned and asked for permission to
proceed. Otherwise the file should be copied without any further interaction
with the user.


Thanks in advance


Report Offensive Message For Removal


Response Number 1
Name: Mik
Date: November 13, 2001 at 04:47:56 Pacific
Reply: (edit)

Try "man cp" and "man bash". They should help you a bit more.

To check if a file exists:
if [ -e $2 ]

To copy a file without user interaction:
cp -f $1 $2

I'm not gonna do your homework assignment. And I'm sure you can figure out the rest.

Mik


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: a question about bash shell script

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 6 Days.
Discuss in The Lounge