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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

a question about bash shell script

Reply to Message Icon

Name: stewchicken
Date: November 12, 2001 at 13:45:34 Pacific
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



Sponsored Link
Ads by Google

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

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


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: a question about bash shell script

Shell script under windows www.computing.net/answers/programming/shell-script-under-windows/18937.html

A question about ListBoxes... www.computing.net/answers/programming/a-question-about-listboxes/13010.html

Shell script & Word Macro www.computing.net/answers/programming/shell-script-amp-word-macro/5931.html