What is the purpose of using the -i option with the mv command?

The purpose of using the -i option with the mv command is to enable interactive mode. When this option is used, it prompts you for confirmation before overwriting an existing file in the destination.

Key Points:

  • Prevents Accidental Overwrites: If the destination file already exists, you will receive a prompt asking if you want to overwrite it.
  • User Control: You can choose to proceed with the overwrite or cancel the operation, providing an extra layer of safety.

Example:

mv -i file.txt destination/

If destination/file.txt exists, you will see a prompt like:

mv: overwrite 'destination/file.txt'? 

This option is particularly useful for preventing data loss when moving files.

0 Comments

no data
Be the first to share your comment!