Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2009

    cp -r with overwrite

    I need to copy all /etc directory and subdirectory to another /etc (source and destenation name is same)
    So all need to be replace (all destenation files and folders must replace with source files and directorys)

    i know "cp -r /root/etc /etc" is ok for above details.
    but its need to type "y" caracter for each file replacement.
    How can run this command for automatic replacement?

  2. #2
    Join Date
    Aug 2009
    Use 'cp -rf'.

  3. #3
    Join Date
    Oct 2005
    Try --force, that is, "cp -r --force source dest".

    If it still asks you to confirm, "cp" might have been an alias with mandatory confirmation. If this is the case, try directly executing /bin/cp if you can, i.e. "/bin/cp -r --force source dest"

  4. #4
    Join Date
    Apr 2002
    Pipe it with yes:

    yes | cp -r /root/etc /etc
    Though, again it is worth mentioning that this will automatically overwrite files in /etc with their /root/etc counterpart.

  5. #5
    Join Date
    Jun 2008
    I think cp is normally aliased with cp -i as that required the yes option. You can un alias it and then try to cp -f option you can confirm it by using the command "type cp" in shell. Then unalias cp and try to use cp -f

    or else cp -rf after unalias cp command
    Last edited by ianeeshps; 10-26-2009 at 10:10 PM.

  6. #6
    Hello every one
    try this command

    cp -rf --reply=yes /etc/* /(new path)

  7. #7
    Join Date
    Apr 2009
    Kerala, India
    The cp command with the switch -i or --interactive will cause cp to prompt before every overwrite.

    If you haven't specified this explicitly, it would have been aliased in your .bash_profile or .bashrc file.

    To check this, type in alias at your command prompt and check if cp has been aliased to cp -i

    remove this line from the .bashrc file
    alias cp='cp -i'

    You may alternatively use the unalias command

    unalias cp

    Hope this helps

  8. #8
    Join Date
    Oct 2004
    Kerala, India
    unalias cp

    This should work in this case.

Similar Threads

  1. cp -r without overwrite prompt
    By Christopher in forum Programming Discussion
    Replies: 14
    Last Post: 07-15-2014, 04:54 AM
  2. Cpanel Backup (Overwrite?)
    By dwessell in forum Hosting Software and Control Panels
    Replies: 2
    Last Post: 09-25-2006, 04:43 PM
  3. overwrite command
    By neonix in forum Hosting Security and Technology
    Replies: 4
    Last Post: 10-19-2005, 01:01 PM
  4. Overwrite permission denied
    By Serverplan in forum Hosting Security and Technology
    Replies: 1
    Last Post: 03-11-2005, 09:41 PM
  5. Can overwrite in FTP due to server timezone dif?
    By DannyITR in forum Hosting Security and Technology
    Replies: 2
    Last Post: 10-23-2003, 10:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts