Can the cp command copy both files and directories?

0156

Yes, the cp command can copy both files and directories.

Copying Files:

To copy a single file:

cp source_file destination_file

Copying Directories:

To copy a directory and its contents, you need to use the -r (recursive) option:

cp -r source_directory destination_directory

Example:

cp -r ~/project ~/backup_project

This command copies the entire project directory and its contents to a new directory named backup_project.

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

0 Comments

no data
Be the first to share your comment!