The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Putting screen output in a log file nsutti Shell Programming and Scripting 5 11-06-2007 05:47 PM
How to place restrictions in a directory coburn UNIX for Dummies Questions & Answers 3 11-03-2006 06:19 PM
Setting password restrictions for all users drathbone UNIX for Dummies Questions & Answers 2 03-03-2006 08:02 PM
putting a timestamp in a file rocker40 UNIX for Dummies Questions & Answers 2 10-22-2003 12:56 PM
UNIX Filename length restrictions? xmeh UNIX for Dummies Questions & Answers 2 06-28-2002 04:14 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-11-2002
thoffpauir thoffpauir is offline
Registered User
  
 

Join Date: Apr 2002
Posts: 1
putting restrictions when copying file

I would like to create a command to copy a file with a restriction- if the file exists at the copy destination, the copy does not occur and message is provided that file already exists.
  #2 (permalink)  
Old 04-11-2002
Kelam_Magnus's Avatar
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
You need to create a script that tests for the file to exist and gives you the option to overwrite or not.

do a man on the test command. That should help you.

Use an "if then else" structure to create it.

if <file exists>
then < YES, file exists copy denied>
else < NO, copy new file to direcotry>
fi
  #3 (permalink)  
Old 04-12-2002
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
If it's interactive, you may be able to use "cp -i here /tmp/there"
It will prompt you before overwriting.
  #4 (permalink)  
Old 04-12-2002
Kelam_Magnus's Avatar
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
I don't know what I was thinking. I was distracted by a problem that I was having on a system at work.

Yes, of course, cp -i.

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0