Copy
This page was last updated on July 18, 2009.
Copy a file:
- This will overwrite an existing file by the same name in the destination without warning you.
-
cp file /destination
Copy a file interactively:
- This will ask permission to overwrite an existing file by the same name in the destination. If the destination doesn’t contain a file by the same name, the command will not run interactively.
-
cp -i file /destination
Copy the files in the current directory:
- This does not ask for permission:
-
cp * /destination
Copy the files in the current directory interactively:
- This will ask permission to overwrite existing files, but not directories. If the destination doesn’t contain files by the same name, the command will not run interactively.
-
cp -i * /destination
Copy a directory and its subdirectories:
- This does not ask for permission:
-
cp -r /source /destination
Copy a directory and its subdirectories interactively:
- This will ask permission to overwrite existing files, but not directories. If the destination doesn’t contain a directory by the same name as the source directory, the command will not run interactively.
-
cp -ir /source /destination
Obligatory Happy Ending
And they all lived happily ever after. The end.
Comment: