#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    Akron, Ohio
    Posts
    105
    Rep Power
    14

    command for copy or duplicate a directory


    what is the command for copy or duplicate a directory?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    191
    Hi!

    the unix copy command is:
    cp -dpR source(s) destination

    never omit the destination! cp will try to overwrite the last file in your source directory!

    -R says recursively, -p preserve attributes and i canīt remember -d... try "man cp" and "help cp"
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Kamloops, BC, Canada
    Posts
    55
    Rep Power
    13
    One thing to watch for, depending on the Unix system you are using: cp -R directory/ newdirectory and cp -R directory newdirectory can do two different things. On some systems, the / can mean to copy the files in the directory to the new location, or it can mean to copy the entire directory tree.

    For instance:
    Code:
    $ ls test/
    file1
    file2
    file3
    $ cp -R test newtest
    $ ls newtest/
    test
    $ ls newtest/test/
    file1
    file2
    file3
    Code:
    $ ls test/
    file1
    file2
    file3
    $ cp -R test/ newtest
    $ ls newtest/
    file1
    file2
    file3
    The least ambiguous way to make sure it always works the ways you want:
    Code:
    $ mkdir newtest
    $ cp -R test/* newtest/
    Linux is for those who hate Windows.
    FreeBSD is for those who love UNIX.
    -------
    Have you read The Handbook yet?
    How about The FAQ?
    Have you searched the mailing lists?
    Or read any of the man pages?
    Have you searched the web for BSD resources?
    In short, have you done your homework yet?

IMN logo majestic logo threadwatch logo seochat tools logo