Go Back  HTML Forums - Free Webmaster Forums and Help Forums > SERVER ADMINISTRATION > Unix Administration
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 11-18-2007, 04:28 AM
  #1
mcbootus
Warrior (Level 8)
 
Join Date: Aug 2006
Location: london
Posts: 76
iTrader: (0)
mcbootus is an unknown quantity at this point
Smile UNIX Copy command problem

Hi all,

I have a linux server and regularly need to copy the contents of a cache folder into my master website folder. The problem is the destination folder contains exactly the same file names as the source folder and whatever copy command I try I am always left with an overwrite prompt message per item, but because there are over 1000 files I do not want to see an over write prompt, I just want a forced overwrite.

I have tried these two commands but I cannot avoid the overwrite prompt with these:

cp -rf /root/home/folder1/cache /root/home/folder2/cache

or

cp -rf /root/home/folder1/cache/* /root/home/folder2/cache


Does anyone know a way to avoid the overwrite prompt please?

Thanks in advance!

Bootus
__________________
Bootus McManus
http://www.veryquiet.com
mcbootus is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 11-18-2007, 06:52 PM
  #2
mikeyp
Part Time Lurker
 
mikeyp's Avatar
 
Join Date: Aug 2002
Location: Doylestown, PA
Posts: 1,554
iTrader: (0)
mikeyp is on a distinguished road
i would have thought that the -rf would have done what you want. Try doing an rm right before that

rm /root/home/folder2/cache/* | cp -rf /root/home/folder1/cache/* /root/home/folder2/cache
__________________
Like MLB? Like the Phillies? Check out PhilliesOnline
Facebook | Personal Site | Wikipedia Profile | My last.fm | Browser Shots
mikeyp is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 11-21-2007, 01:07 AM
  #3
mgolvach
Battler (Level 3)
 
Join Date: Oct 2007
Posts: 28
iTrader: (0)
mgolvach is an unknown quantity at this point
Also, I know RedHat likes to include aliases for cp, mv and rm (to "cp -i," "mv -i" and "rm -i" respectively) so you're doing an interactive copy even when you're forcing it. I think you can find them in either /etc/profile or /etc/bashrc. If you remove these aliases, the problem should go away.

Just typing "alias" at the command line when you log in should show you these.

Hope that's helpful

, Mike
__________________
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
mgolvach is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 11-28-2007, 04:14 AM
  #4
mcbootus
Warrior (Level 8)
 
Join Date: Aug 2006
Location: london
Posts: 76
iTrader: (0)
mcbootus is an unknown quantity at this point
Hi guys,

Thanks for the advice.

mikeyp - Currently I am doing the rm just before the copy but this has other complications which causes the copy to fail occasionally.

mgolvach - this sounds really promising - i suspected there was a server issue causing the cp to misbehave - let me try your suggestion and get back to you.

Thanks again!



McB
__________________
Bootus McManus
http://www.veryquiet.com
mcbootus is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 12-09-2007, 06:44 AM
  #5
mcbootus
Warrior (Level 8)
 
Join Date: Aug 2006
Location: london
Posts: 76
iTrader: (0)
mcbootus is an unknown quantity at this point
Thanks for the info guys - I got a solution!

Yeah there are aliases on the system, I tried to delete them but they seemed to come back. I found a quicker solution, you can override an alias by adding ' ' around the command - this will force any settings you specify over the alias.

Like this:

'cp' -rf /root/home/folder1/cache/* /root/home/folder2/cache

Works a treat!

Thanks again.

McB
__________________
Bootus McManus
http://www.veryquiet.com
mcbootus is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 05-07-2008, 10:27 PM
  #6
mgolvach
Battler (Level 3)
 
Join Date: Oct 2007
Posts: 28
iTrader: (0)
mgolvach is an unknown quantity at this point
Nice

I never knew that. I got in the habit of putting

unalias rm
unalias cp
unalias mv

in all my .profiles and .bashrc's

Good show

, Mike
__________________
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
mgolvach is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Reply


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 11:08 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.