The -i option (or --interactive) in the cp command is used to prompt the user for confirmation before overwriting an existing file at the destination.
Key Features:
- Prevents Accidental Overwrites: If the destination file already exists, the command will ask the user whether they want to overwrite it.
- User Decision: The user can respond with
y(yes) to proceed with the overwrite orn(no) to skip the operation.
Example Usage:
cp -i source_file.txt destination_file.txt
If destination_file.txt exists, the terminal will display a prompt like:
cp: overwrite 'destination_file.txt'?
This option is particularly useful for avoiding unintentional data loss by ensuring that users are aware of the potential consequences of their actions before proceeding with file operations. If you have any further questions or need more details, feel free to ask!
