What does the '-r' option do when used with the 'cp' command?

01.2k

The -r option (or --recursive) in the cp command is used to copy directories and their contents recursively. This means that when you use this option, the command will copy not only the specified directory but also all of its subdirectories and files.

Purpose:

  • Copy Entire Directory Structures: The -r option allows you to duplicate an entire directory along with all its nested files and subdirectories in one command.

Example Usage:

cp -r source_directory destination_directory

In this example, source_directory and all of its contents (files and subdirectories) will be copied to destination_directory.

Important Note:

  • Without the -r option, the cp command will not copy directories and will return an error if you try to do so.

If you have any further questions or need more details, feel free to ask!

0 Comments

no data
Be the first to share your comment!