the cp command in linux

I like Linux and I like apple and I even like windows for the most part.  Now in Windows you wouldn’t get a change to the base functionality of xcopy, but here in linux world I have exactly that in the cp command.  it’s always been easy to overwrite a whole slew of files at once if I was say updating a bunch of web sites to a new version of WordPress.  All I had to do was use the –reply=”no|yes” and it would automatically respond to the interactive request to overwrite the files with a yes.  I loved it. It made wading through all the updates to the umpteen different WordPress sites scriptable and fast.  No longer.  The –reply=”” command has been removed from cp.  So now I get to find another way to do it and it’s going to be cumbersome and annoying.  I wonder if I can find an older copy of cp that still has the –reply…. *sighs*



3 thoughts on “the cp command in linux”

  • Yeah, that parameter has been deprecated for a few years but I didn’t think it had been removed yet. If you want to revert to a previous version, you can find the cp source in GNU coreutils: ftp://ftp.gnu.org/gnu/coreutils/
    However, cp should be non-interactive by default. Depending on your Linux distro, it might be aliased to ‘cp -i’, the interactive mode. This can be overridden by explicitly calling /bin/cp, or by removing the alias from your shell profile.

  • You’re right! I finally caught on to the aliasing over the weekend. I was finally able to enjoy the bliss of non-interactive copying again. Apparently the difference in cp happened when I moved from CentOS 4 to CentOS 5. I’ll happily use the forced no-alias “cp” until I get off my lazy but and fix the alias. Thanks for the link to the source! 😀

  • Just wanted to share some more tips,

    1) it removes the alias by typing just

    #’cp’ -rf /home/test/files/* /home/test2/files2

    2) copies all the files and subdirectories in files into the files2 directory. If files with the same name exist or it’s prompted to overwrite the file it answers yes.

    #yes | cp /home/mark/files/* /home/zach/files2

Leave a Reply

Your email address will not be published. Required fields are marked *