cp all files and subdirectories in a directory ksh

81,067

Solution 1

What *nix do you have?

Under Linux you use normally:

cp -r <source> <target>

and if you want to copy all the same attributes (aka owner, etc.):

cp -a <source> <target>

Solution 2

cp -r dir1 dir2

-R, -r, --recursive
          copy directories recursively
Share:
81,067

Related videos on Youtube

user1058398
Author by

user1058398

Updated on September 18, 2022

Comments

  • user1058398
    user1058398 almost 2 years

    How can I do a cp to copy all files including all sub-directories in the current directory.

    I looked at the man page, but I can't figure out how to do it.

    EDIT: (my *nix is Linux)

  • user1058398
    user1058398 over 10 years
    Sorry, tell me if I'm wrong but, it will copy all subdirectories recursively ? So it'll copy all the files located in them in my current directory ?