Re: Help with command - cp
On 1/27/14, Mathias Bauer <mbauer@gmx.org> wrote:
> * Mr Smiley wrote on 2014-01-26 at 20:56 (+0000):
>
>> > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B
>>
>> If you don't put a / after B it will copy all files to a file
>> called B
>
> No, obviously not.
true
>> So your above
>> cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B
>> Should be
>> cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B/
>
> If the target directory *exists* the trailing slash will *not* be
> necessary:
true
and to state what should be obvious: if the target directory does
*not exist*, then the trailing slash will, if you end up copying just
one file, cause an error to be displayed rather than the wrong action
to occur.
>> Also when using rsync, i use the following
>>
>> rsync -vrthiP --progress --stats source/ destination/
>>
>> This also checks for and only updates changed files on any
>> subsequent rsync from A to B
>>
>> Don't forget the / at the end, even rsync will copy everything to a
>> file rather than the wanted directory if you miss of the /
>
> That's not correct. In contrast to the slash trailing the
> *source*, the final slash trailing the *target* is completely
> irrelevant. See my other mail.
True. But it does encourage (to my experience) thinking a little bit
more about what I'm doing, because I do sometimes still use cp etc.
Reply to: