Linux Basics

28 / 107

Copy a directory into another directory

We have to use -r or -R option with cp to copy directories. Remember, the directory gets copied along with it's sub-directories.

  1. Create a directory "src"

    mkdir src
  2. Create a file in "src"

    touch src/myfile.txt
  3. Create a directory "proj"

    mkdir proj
  4. Copy the src into "proj"

    cp -r src proj

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...