?
Solved

prompt before overrite : cp in linux

Posted on 2010-04-01
5
Medium Priority
?
507 Views
Last Modified: 2013-12-06
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)
0
Comment
Question by:idforpg1
  • 2
  • 2
5 Comments
 
LVL 58

Expert Comment

by:amit_g
ID: 29402737
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]
0
 
LVL 7

Accepted Solution

by:
ajay_mhasal earned 2000 total points
ID: 29426165
Hi,

Just run following command on terminal and then try copying again you issue will be resolved

unalias cp

But above change is temporary i.e. you need to run this command every time you login and if you wish to make it permanent then edit file ".bashrc"  ( Pl. note "." before bashrc this is not typing mistake) located at home dir of that user and delete line "alias cp='cp -i'" to edit .bashrc file use following command.

vi ~/.bashrc
0
 
LVL 7

Assisted Solution

by:ajay_mhasal
ajay_mhasal earned 2000 total points
ID: 29426555
HI,

After running unalias command or after editing .bashrc file  mentioned in my previous post you dont need to pass additional parameters to cp command, simply use cp command and now it will never prompts you to type yes/no before overwriting!

eg.

cp -r <source dir> <dest dir>
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 29455717
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
0
 
LVL 58

Expert Comment

by:amit_g
ID: 29510853
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.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question