How do I copy a whole structure of directory ?

How do I copy a whole structure of directory ?

Post by standbyme_.. » Wed, 20 May 1998 04:00:00



Unix A:  \u01\test\
                          ......
                          ......

Unix B:  \u01\

I need all \test\ and everything under it on Unix A to be copied over to

\u01\ on Unix B.

I haven't figure know how this can be done in Unix.   I need Cut/Paste
as in Windows NT.

Thanks,

 
 
 

How do I copy a whole structure of directory ?

Post by Steven L Bossi » Wed, 20 May 1998 04:00:00


You can use
     cp -pR <source> <target>
to copy a tree (R mean recursive) and retain the file attributes (p). If
there are links in the <source>, the cp command will find the files linked
and copy the files, not just the links. For example, if you have done
something like
     ln  -s  /u01/test/subdir/FILE  /u01/test/otherSubdir
to create a  link to FILE in the otherSubdir, then cp will copy FILE to the
<target>.

To find out if you have any links in the <source> tree, use
     find <source> -L -print        (L might not be the right option. use
'man find'.)
or
    ls -lR <source> | grep "^l"      (ugly but it will work)

If you need to retain the links, you can use tar to first create a copy
  tar -cvf /wherever/test.tar /u01/test
and then untar it by cd'ing to Unix B:/u01 and using
  tar -xvf /wherever/test.tar

You can do the tar without creating the temporary file (test.tar) by using a
pipe.

Steve Bossie

 
 
 

How do I copy a whole structure of directory ?

Post by Anthony Mandi » Thu, 21 May 1998 04:00:00



> I need all \test\ and everything under it on Unix A to be copied over to
> \u01\ on Unix B.

> I haven't figure know how this can be done in Unix.   I need Cut/Paste
> as in Windows NT.

        No, you need ufsdump, tar or cpio etc. as in UNIX.

-am

 
 
 

How do I copy a whole structure of directory ?

Post by andy » Thu, 21 May 1998 04:00:00


try:

cd /test
rcp -r * unixb:/uo1

assuming you have .rhosts setup

--
Andy

-----------------------------
All viewpoints expressed in this communication are those of the individuals
involved and do not reflect the opinions or positions of any other indivdual
or organisation unless expressly stated thus.



>> I need all \test\ and everything under it on Unix A to be copied over to
>> \u01\ on Unix B.

>> I haven't figure know how this can be done in Unix.   I need Cut/Paste
>> as in Windows NT.

> No, you need ufsdump, tar or cpio etc. as in UNIX.

>-am

 
 
 

How do I copy a whole structure of directory ?

Post by Rick Nizia » Thu, 21 May 1998 04:00:00


To copy directory structures to different machines is a little tricky
try something like this:

on UNIX-A:
        cd /u01
        tar cvf - ./test | rsh UNIX-B "(cd /u01; tar xvf -)"

That should do it.. providing you can rsh commands from unix-a to unix-b
if you get "permission denied", go to unix-b and put the following line
in /.rhosts
        unix-a root

then try:
        unix-a% rsh unix-b df

If that works, you should be all set.

Regards,

        Rick Niziak


> Unix A:  \u01\test\
>                           ......
>                           ......

> Unix B:  \u01\

> I need all \test\ and everything under it on Unix A to be copied over to

> \u01\ on Unix B.

> I haven't figure know how this can be done in Unix.   I need Cut/Paste
> as in Windows NT.

> Thanks,

 
 
 

How do I copy a whole structure of directory ?

Post by standbyme_.. » Thu, 21 May 1998 04:00:00


Hi Rick,

This solution is so elegant, so beautiful. It works.

However, when I have this case:

Unix A:  \u01\test
Unix B:  \u05\

I need \test on Unix A to be copied onto \u05 also as \test, then the same
command doesn't work.   I got an error: No such file or directory.
I guess the error is because of no \u01 in Unix B but only \u05

Can you help ?

Oh heaven, I'm rocket scientist drop-out.

For NT: Network Neighborhood/Cut/Paste- Any dummy can do it in NT.


> To copy directory structures to different machines is a little tricky
> try something like this:

> on UNIX-A:
>         cd /u01
>         tar cvf - ./test | rsh UNIX-B "(cd /u01; tar xvf -)"

> That should do it.. providing you can rsh commands from unix-a to unix-b
> if you get "permission denied", go to unix-b and put the following line
> in /.rhosts
>         unix-a root

> then try:
>         unix-a% rsh unix-b df

> If that works, you should be all set.

> Regards,

>         Rick Niziak


> > Unix A:  \u01\test\
> >                           ......
> >                           ......

> > Unix B:  \u01\

> > I need all \test\ and everything under it on Unix A to be copied over to

> > \u01\ on Unix B.

> > I haven't figure know how this can be done in Unix.   I need Cut/Paste
> > as in Windows NT.

> > Thanks,

 
 
 

How do I copy a whole structure of directory ?

Post by Anthony Mandi » Fri, 22 May 1998 04:00:00



> Hi Rick,

> This solution is so elegant, so beautiful. It works.

> However, when I have this case:

> Unix A:  \u01\test
> Unix B:  \u05\

> I need \test on Unix A to be copied onto \u05 also as \test, then the same
> command doesn't work.   I got an error: No such file or directory.
> I guess the error is because of no \u01 in Unix B but only \u05

> Can you help ?

> Oh heaven, I'm rocket scientist drop-out.

        Try and get your slashes right for a start. Then set up a
        ".rhosts" file on your Unix B target then use the rcp
        command vis -

                cd /u01; rcp -r test unixB:/u05

        Piece o' cake.

-am

 
 
 

How do I copy a whole structure of directory ?

Post by Kevin J.Del » Fri, 22 May 1998 04:00:00


That's what happens with you use DOS boxes for too long! :-))

************************************************************************

Unix Systems
Administrator
Dow Jones Markets

Tel: +44 171 832 9000
Fax: +44 171 832 9390
***********************************************************************

<snip>

Quote:> > However, when I have this case:

> > Unix A:  \u01\test
> > Unix B:  \u05\

>    Try and get your slashes right for a start. Then set up a
>    ".rhosts" file on your Unix B target then use the rcp
>    command vis -

>            cd /u01; rcp -r test unixB:/u05

>    Piece o' cake.

> -am

 
 
 

1. copying a directory structure with a particular file in directories below

Hello,
I need some help/advise on how to copy a directory structure with a
particular file in directories below the start directory.

Let's say I have many text files [*.txt] with many data files and other
files [*.data, *.*]
The directory I want to copy across to another area with only the text
files but which also retains the directory structure.

i.e.,

[root_directory]
 |__[data]
       |__[directory_1]
       |__[direcotry_2]
       |    |__[directory_2.1]
       |
       |__[directory_3]
       |
       |__[directory_N]

I want to copy the directory [data] to another area with just the *.txt
files but retain the directory structure.

I tried to do this

cp -r `find /[root_directory]/[data] -name "*.txt"` .

NOTE: The above when I include the square brackets is meant to
represent the full name of the
directory and is not to be confused with anything else.

cp -r `find /root_directory/data/ -name "*.txt"` .

When doing this, all I get is the *.txt files without the directory
structure. If the *.txt files have the same name it will cause
problems. So I can copy the directory structure it would be great.

I hope you can understand the issue/problem statement from my
explanation.
If you have any questions please ask me.

Thanks,
ROuNIN

2. Where to Learn Unix C Programming??

3. how to ftp a whole directory structure (with subdirs)

4. More Semaphores - Solaris 2.5

5. How to copy a whole directory to another server

6. AGP problems, picture flickering

7. copying whole directories CLI ftp client

8. IRQ Conflict w/ NE2000 [?]

9. Copy the whole directory

10. HELP:2 ques: Copying large directory structure and mkfs

11. copying directory structure only

12. automatically copy and rename directory structure

13. Bash shell script to sort files by date and copy to directory structure