Cp command copies too much

Cp command copies too much

Post by Mike Jorda » Sat, 10 Jul 1999 04:00:00



I've been coping directories from one place to another and ran into a
stange problem.  I need to retain the date/time stamp as well as ownership
of the files so I used the following command:

cp -p -R fromDirName toDirName

It works fine except it also copies files that are in other directories. I
noticed this happening once before but didn't take the time to check it
out as it only copied a couple of extra files.

Am I using the wrong command to move a directory and all of it's
sub-directories to another location? Or is this something that happens
with the cp command?

Thanks for any suggestions.

Mike

--
-------------------  
Prineville, Oregon (Central Oregon)
Bouvier des Flandres - Carting, Herding & Clicker Training
The Mocassin Telegraph - Cherokee Genealogy
WWW:  http://www.europa.com/~mjordan

 
 
 

Cp command copies too much

Post by Lufi » Sun, 11 Jul 1999 04:00:00


Quote:> cp -p -R fromDirName toDirName

Better is:

$ (cd fromDirName;tar cvf - ./)|(cd toDirName;tar xvf -)

                                          Preji  pekny den, Lufi.
------------ EOM ------------
Lukas FIKER
Institute of Chemical Technology, Prague
Dpt. #990, Computer Center
Technicka 5
166 28 Praha 6
Phone: (+420 2) 2435 3257
Fax:   (+420 2) 2435 3635                              

 
 
 

Cp command copies too much

Post by Ted Linne » Mon, 12 Jul 1999 04:00:00



>I've been coping directories from one place to another and ran into a
>stange problem.  I need to retain the date/time stamp as well as ownership
>of the files so I used the following command:

>cp -p -R fromDirName toDirName

>It works fine except it also copies files that are in other directories. I
>noticed this happening once before but didn't take the time to check it
>out as it only copied a couple of extra files.

>Am I using the wrong command to move a directory and all of it's
>sub-directories to another location? Or is this something that happens
>with the cp command?

>Thanks for any suggestions.

>Mike

If you have symbolic links cp will follow the link and copy the
contents of the file it points to. There is a flag (-h I think) to get
it to copy only the link.

cp -phR  fromDirName to DirName

man cp to check if this is the correect flag.

Ted.
==============================================================

| BSc GradDipDP CNA MACS PCP                                 |
| Nunawading, Victoria , Australia                           |
==============================================================

 
 
 

Cp command copies too much

Post by Mike Jorda » Mon, 12 Jul 1999 04:00:00



: If you have symbolic links cp will follow the link and copy the
: contents of the file it points to. There is a flag (-h I think) to get
: it to copy only the link.

: cp -phR  fromDirName to DirName

: man cp to check if this is the correect flag.

I have seen the h flag in the man pagaes but will have to look again to
see what it was for.  

Thanks

Mike

--
-------------------  
Prineville, Oregon (Central Oregon)
Bouvier des Flandres - Carting, Herding & Clicker Training
The Mocassin Telegraph - Cherokee Genealogy
WWW:  http://www.europa.com/~mjordan

 
 
 

Cp command copies too much

Post by Peter Bennet » Tue, 13 Jul 1999 04:00:00


Or even
cd fromDirName
find . -print|cpio -pdmv toDirName
You can then add a -xdev to the find . -print to prevent it crossing
mount points if you only want to copy the contents of one file system.
Pete.


> > cp -p -R fromDirName toDirName

> Better is:

> $ (cd fromDirName;tar cvf - ./)|(cd toDirName;tar xvf -)

>                                           Preji  pekny den, Lufi.
> ------------ EOM ------------
> Lukas FIKER
> Institute of Chemical Technology, Prague
> Dpt. #990, Computer Center
> Technicka 5
> 166 28 Praha 6
> Phone: (+420 2) 2435 3257
> Fax:   (+420 2) 2435 3635

 
 
 

1. Does the 'cp' command verify the file copied correctly?

I tried searching for this on google, but couldn't come up with an answer.

Does the unix 'cp' command verify that after the source file is copied to the destination
file, that the destination file is the same as the source file?

If so, what does it do to verify this?

TIA

2. telnet with emacs

3. Memory Fault using the copy command (cp) on HP-UX 11.0

4. DIP & Compuserve

5. Need help copying subdirectories (cp -r)

6. Red Hat Network Applet

7. DOS copy faster than Linux cp (SCSI)!!

8. HELP! Please

9. Solaris cp won't copy?

10. "cp -ax" copies /proc?

11. ?Does cp copy hidden files or not?

12. CP copies 3 times slower than Konqueror

13. copying files using shell (cp)