Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Where is the difference between this commnads

    Before I use
    cp -R * /where want to place/ but I can't find how to use it with (pick all yes) when copy files that already exist.

    I find this cp -pr and this overwrite my files

    Just my question is: Can You tell me where is the difference between recursively copy files and just copy files (speed) or ?

    Thank You

  2. #2
    Linux Enthusiast
    Join Date
    Dec 2011
    Turtle Island West
    cp -R or cp -r recurses through directories. It dives into the subdirs and copies everything in the entire tree branch.

    cp -p preserves the datestamps and stuff so the copied files have the same stamps as the originals. I use that all the time.

    cp _DOES_NOT_ overwrite files by default unless you use the -f switch. It will ask you everytime.

    cp -f will copy and overwrite anything without asking. It's a bit dangerous, so use it with much caution.

    Maybe you have an alias 'cp=cp -f'. Try typing 'alias' and see if you have:

    alias cp='cp -f'

    in there. If so, remove it, pronto. Check in ~/.bashrc, ~/.bash_profile, ~/.profile, that kind of thing. Find out where it's been set.

    Also, try 'man cp'. The manual pages are your friends.

  3. #3
    Thank You and for what is -r then

    cp -f back me : cp: omitting directory

    cp -pr -f ask me

    what to use to work Thank YOu

  4. $spacer_open
  5. #4
    Quote Originally Posted by gladiator6
    for what is -r then
    From the cp man page:
           -R, -r, --recursive
                  copy directories recursively
    cp -f back me : cp: omitting directory
    is "back" a dir? If so, you need "-r" or equivalent.

    cp -pr -f ask me
    On your system, it may be that cp is aliased to "cp -i". try this command to see:
    alias cp
    if it returns something like:
    alias cp='cp -i'
    then that is your problem.

    you can always use the full path to the binary to avoid the use of an alias, e.g.:
    /bin/cp -f foo bar

Posting Permissions

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