Operating System - HP-UX
1836462 Members
2205 Online
110101 Solutions
New Discussion

copy files from here to there...

 
SOLVED
Go to solution
Ron Irving
Trusted Contributor

copy files from here to there...

Ok...here's what I need: I have to copy a bunch of files, (about 1300,) from point a to point b. What's the easiest way to do that?

eg: /dir/dir1/files
--to--
/dir3/files

Thanks a HEAP in advance

Ron Irving
Should have been an astronaut.
6 REPLIES 6
Rodney Hills
Honored Contributor

Re: copy files from here to there...

A quick way is to.

cd /dir1/dir2
tar cf - . | (cd /dir3 ; tar xf - )

This will keep all permissions and ownerships.
Unfortunately it does not carry over ACLs.

-- Rod Hills
There be dragons...
JACQUET
Frequent Advisor

Re: copy files from here to there...


1?)
# cd /dir/dir1/files ; cp -rp ./ /dir3/files

2?)
# cd /dir/dir1/files ;
# tar cvpf - ./ | ( cd /dir3/files ; tar xf - )

You can do it also with cpio, dd, ..

PJA.

PJA
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: copy files from here to there...

Hi Ron:

I would use the cpio -p method:

e.g.
cd /dir/dir1
find . -print | cpio -pudvm /dir3

that will get everything in the current directory and copy it to the /dir3 directory

If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: copy files from here to there...

Hi Ron:

This is an easy way:

# cd /sourcedirectory
# find . | cpio -pudlmv /destinationdirectory

This creates directories as needed, preserves modification timestamps, and reports the process of the copy as it proceeds.

Regards!

...JRF...
David Navarro
Respected Contributor

Re: copy files from here to there...

Hi, Ron When I need to do that I excute:

cd /dir/dir1/files
find . | cpio -pdumvbx /dir3/files

If you do that, you will respect links, device files ( if there's any), perms, owner, etc.
I do this for migrating purposes.


harry d brown jr
Honored Contributor

Re: copy files from here to there...


cp -rp /dir/dir1/files /dir3

Live Free or Die