LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-12-2003, 02:26 PM   #1
eXor
Member
 
Registered: Mar 2002
Location: Sweden
Distribution: Slackware 10.1
Posts: 103

Rep: Reputation: 15
Cp not overwrighting?


How do I do so that CP is not overwrigthing files if it has an copy in destination directory.

Eg.

First i copy test.log to /tmp/

then later i do the same thing.

Then I wan't it to NOT to overwright. I just wan't nothing to happen. No backup just nothing.
 
Old 06-12-2003, 02:30 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
I don't think you can. You could use "-i" to make it prompt you. If this is in a script then you could just check if the file exists before you try to copy.
 
Old 06-12-2003, 02:34 PM   #3
eXor
Member
 
Registered: Mar 2002
Location: Sweden
Distribution: Slackware 10.1
Posts: 103

Original Poster
Rep: Reputation: 15
how do I do this test. I'm not so god at scripting.
 
Old 06-12-2003, 02:53 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Code:
if [ -e /tmp/test ]; then
echo File /tmp/test exists
fi
 
Old 06-12-2003, 02:55 PM   #5
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
or better for you
Code:
if [ ! -e /tmp/test ]; then
cp /home/test /tmp/test
fi
 
Old 06-12-2003, 02:56 PM   #6
eXor
Member
 
Registered: Mar 2002
Location: Sweden
Distribution: Slackware 10.1
Posts: 103

Original Poster
Rep: Reputation: 15
thx..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration