The cp command in Bash is used to copy files and directories from one location to another.
Copy Command Syntax and Explanation
The basic syntax of the cp command is:
cp [OPTION]... SOURCE... DESTINATION
- SOURCE: The file or directory you want to copy.
- DESTINATION: The location where you want to place the copied file or directory.
- OPTION: Optional flags that modify the behavior of the
cpcommand.
Commonly used options include:
-ror-R: Recursively copy directories and their contents.-i: Prompt before overwriting an existing file.-u: Copy only when the SOURCE file is newer than the DESTINATION file or when the DESTINATION file is missing.-v: Verbose mode, which shows the files being copied.-T: Treat the destination as a normal file. This is useful when you don’t want to create a new directory at the destination.-f: Force the copy operation by removing the destination file if it cannot be opened.