terminal.cab
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.

Command of the day No. 9: cp -i. Purpose: Copies, but asks before overwriting a file. Example: cp -i todo.txt Documents/notes.txt; head -n 1 Documents/notes.txt. Caution: Without -i, cp overwrites the target silently and the old content is gone. Check first: ls target shows whether a file with that name already exists. Remember: n keeps, y replaces: -i gives you the choice.
The same card as an image, 1080 x 1350 pixels.

Today's card ยท All cards so far