cp (copy files)
Copies a file into a new file or into a new directory with the same name. If the new file already exists, copy overwrites the existing file with the new file.
Format: cp filename filename
Examples: cp prog1 prog2
cp prog1 /home/janet
The second example copies prog1 into /home/janet/prog1. After a cp command, two files exist: the original file plus the new file it was copied into.
Opt | What It Does | Example |
---|---|---|
-i | Prompt before overwriting a file | cp -i report1 report2 |
-v | Display name of file being copied | cp -v rep1 dir1 |
Get Spring Into Linux® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.