- No.
- 9
- Date
- Learning goal
- Terminal Start, lesson 6
- Level
- 2 of 3
Command of the day No. 9: cp -i
Purpose: Copies, but asks before overwriting a file.
Syntax: cp -i source target
Example:
cp -i todo.txt Documents/notes.txt
cp: overwrite 'Documents/notes.txt'? n
head -n 1 Documents/notes.txt
Buy milk Output from the simulator, as on a real Linux.
Options:
Try it in the terminal Share image
Fills in the command. Nothing runs until you press Enter. cp asks before it overwrites: n keeps the old file, y replaces it.