LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cp -u bugs me with skip/overwrite y/n questions (https://www.linuxquestions.org/questions/linux-general-1/cp-u-bugs-me-with-skip-overwrite-y-n-questions-592349/)

oskar 10-16-2007 05:17 PM

cp -u bugs me with skip/overwrite y/n questions
 
I'm backing up my ubuntu home folder from Fedora 7 because I'm in the course of reinstalling -Ubuntu freezes, and I can't figure out why... Started a thread last week: http://www.linuxquestions.org/questi...ck-ups-590324/

I was almost finished copying when I accidently closed the terminal window. I figure cp -rpuv (recursive, preserve owner, update, verbose) should resume it, but it asks me again for every file that already exists.

Of course I'm deleting and copying again... Not worth the trouble, but if anybody has any idea why it doesn't work, or what my alternatives are...

The_JinJ 10-16-2007 05:27 PM

Is -i set in your ~/.bash_alias?

oskar 10-16-2007 05:36 PM

come again? :)

I suppose you mean .bash_profile (I don't have a .bash_alias)

Code:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH


andrews-mark 10-16-2007 07:31 PM

Hi - it sounds like the -i flag for cp is on by default. I presume that this is what The_JinJ was suggesting. Often there are bash aliases, set in e.g. /etc/bashrc, or ~/bash_aliases, and cp could be set to cp -i.

You can list all current alias with
Code:

alias -p
(at least, I think that will list all aliases)

However, even with the -i flag, the -u flag should lead you to skip over any file already copied, so there should be no over-write issues to query in the first place. In that case, it is a bit puzzling.

-mark

BrianK 10-16-2007 09:31 PM

alternative:

rsync -vax source dest


... be careful with source, /path/ is not the same as /path.

use -n for dry run to see if it's doing it correctly.

matthewg42 10-16-2007 09:59 PM

to see if cp is aliased, type:
Code:

alias cp
If you get back something like:
Code:

alias cp='cp -i'
Then it is. If this is the case, you can opt to run the command directly - not using the alias - by prefixing it with a backslash. i.e.
Code:

\cp -rpuv ...
If you don't ever want this -i option, find the entry in your .bash_profile, .bashrc or and file which is sourced from these, and comment out / delete the line with this alias. The change will only affect new sessions.


All times are GMT -5. The time now is 09:08 PM.