Find the answer to your Linux question:
Results 1 to 4 of 4
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2012
    Posts
    4

    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 User
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    362
    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
    Just Joined!
    Join Date
    Nov 2012
    Posts
    4
    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. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by gladiator6
    for what is -r then
    From the cp man page:
    Code:
           -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:
    Code:
    alias cp
    if it returns something like:
    Code:
    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.:
    Code:
    /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
  •