Link to home
Start Free TrialLog in
Avatar of idforpg1
idforpg1

asked on

prompt before overrite : cp in linux

Hi,

I am new to linux. I use following command but still get interactive prompts "overite ?" for each file. I want to over rite all existing files at destination dir i.e. like "yes to all" in windows.

cp -f -r [source dir] [dest dir]

any suggestions or idea? All I want to do is copy all files and sub directories from source to dest (overwrite files at dest)
Avatar of amit_g
amit_g
Flag of United States of America image

You may have an alias. Try

\cp -f -r [source dir] [dest dir]

however note that with that the sourcedir would be copied inside the destdir. You should use

\cp -f -r [source dir]/* [dest dir]
ASKER CERTIFIED SOLUTION
Avatar of ajay_mhasal
ajay_mhasal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is there a file "-i" in source_dir?

If so, and if you are not willing or allowed to delete it, use

cp -r -- [source dir] [dest dir]

wmp
I would not recommend getting rid of the alias from the profile/bashrc permanently. It is safety net that is needed by everyone no matter how experience one has. One day this would haunt you when you would lose something important. Temporary unaliasing by prefixing the command by \ is safer way.