The cp
(CoPy) command is used to copy a file or directory. You can specify the destination directory to create a copy of the file or directory. You can also use the -r
option to create a copy of a directory.
There are two key arguments in the cp
command.
For example, if you want to make a copy of file_a under your working directory to dir_a under your working directory, run the command below.
cp file_a dir_a
To make a copy with a new name, you can add the new file name in the 2nd argument after the directory path.
For example, if you want to make a copy of file_a with a new name file_a_cp to dir_a, run the command below.
cp file_a dir_a/file_a_cp
To make a copy of a directory, use the -r
option.
For example, if you want to make a copy of dir_a located under dir_b with a new name dir_a_cp, run the command below.
cp -r dir_a dir_b/dir_a_cp
The cp
(CoPy) command is used to copy a file or directory. You can specify the destination directory to create a copy of the file or directory. You can also use the -r
option to create a copy of a directory.
There are two key arguments in the cp
command.
For example, if you want to make a copy of file_a under your working directory to dir_a under your working directory, run the command below.
cp file_a dir_a
To make a copy with a new name, you can add the new file name in the 2nd argument after the directory path.
For example, if you want to make a copy of file_a with a new name file_a_cp to dir_a, run the command below.
cp file_a dir_a/file_a_cp
To make a copy of a directory, use the -r
option.
For example, if you want to make a copy of dir_a located under dir_b with a new name dir_a_cp, run the command below.
cp -r dir_a dir_b/dir_a_cp