Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mv: prompt to rename or overwrite

find /home/csuser/testfiles . -type f -name "*.c" -exec mv '{}' /home/csuser/src/ \;

The above command will simply overwrite files which have the same name. How can I make mv prompt me to either overwrite the existing file or replace it, for each file name which already exists at the target?

like image 647
ECHO Avatar asked Sep 05 '25 03:09

ECHO


1 Answers

The manpage of the mv command (man mv) shows the following entry:

       -i, --interactive
              prompt before overwrite

So, using mv -i ... prompts before overwriting.

like image 128
Dominique Avatar answered Sep 07 '25 21:09

Dominique