[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to overwrite the destination directory by 'cp'?

From: Kamil Dudka
Subject: Re: How to overwrite the destination directory by 'cp'?
Date: Thu, 21 Jan 2010 23:42:19 +0100
User-agent: KMail/1.9.10

On Thursday 21 of January 2010 23:35:13 Peng Yu wrote:
> Suppose I have directory a and b, the following command will copy the
> content of a to b/a, rather than overwrite the directory 'b' by the
> directory 'a'. I'm wondering if there is an option to overwrite 'b'?
> cp -r a b

I don't think something like that is possible with cp itself.  It looks a bit 
dangerous to me anyway.  Instead of that, there is a way to avoid the copy 
operation in such case:

$ cp -r --no-target-directory a b

If you want to destroy content of 'b' and replace with content of 'a', then 
you want to do this:

$ rm -rf b; cp -r --no-target-directory a b


reply via email to

[Prev in Thread] Current Thread [Next in Thread]