cp command force

2

currently there's a xxx dir already in /home/yyy
I'm trying to overwrite it cp -fr ../xxx /home/yyy/
doesn't work still prompts me to overwrite the individual files. how do I fix it?

user15586

Posted 2010-05-05T07:54:20.463

Reputation: 627

Answers

4

Indeed, see if it's aliased. You can do this by typing alias cp. If it's in that list you can remove it by typing unalias. (The default) -i option will be gone too.

Overwriting won't be a problem anymore...

tersmitten

Posted 2010-05-05T07:54:20.463

Reputation: 156

3

or, to circumvent the problem with aliases in the first place, call the cp binary directly. Mostly, this will work:

/bin/cp -fr .../xxx /home/yyy/

Boldewyn

Posted 2010-05-05T07:54:20.463

Reputation: 3 835

2Or escape the command \cp -fr ... – mpez0 – 2010-05-05T13:43:48.160

1

I'll assume you are using BASH or SH as your shell, in which case you can explicitly undo all aliases by prefixing your command line with command. E.g.

command cp -fr ../xxx /home/yyy/

Which would ignore any aliases for cp and any shell-function called cp.

RobM

Posted 2010-05-05T07:54:20.463

Reputation: 575

0

Looking here

-i is ‘interactive’ aka ALWAYS PROMPT, and evidently overrides -f

Make sure your cp is not aliased or something. (run type cp ). As a simple example, the order of the options is important. For instance rm -if f will say nothing. rm -fi f will prompt me before removing f.

nc3b

Posted 2010-05-05T07:54:20.463

Reputation: 1 094

if it's aliased, AFAIK his input should override the alias, because it will be something like cp -i -fr etc. – o0'. – 2010-05-05T11:23:56.217

@Lo'oris: On my system (RHEL 5), the -i overrides the -f. – GreenMatt – 2010-05-05T13:45:39.343