Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yes to all overwrites in interactive mv/cp/rm?

Tags:

command-line

So I've aliased the commands rm/cp/mv to use interactive (-i) mode by default to avoid accidentally deleting things, but sometimes this is pretty inconvenient.

I would like to be able to say 'y' to all the prompts of the form:

mv: overwrite `file_1'? y 
mv: overwrite `file_2'? y 

without typing 'y' many many times. Is there a way to do this?

like image 769
capybaralet Avatar asked Oct 18 '15 21:10

capybaralet


People also ask

How do you say yes to all in Linux?

The y characters from the yes command will respond "yes" to each prompt automatically. Here, the yes command outputs "n" in a constant stream to the rm -i command, answering "no" to all the same questions.

Which option is used with cp command to avoid overwrites?

You can control exactly which attributes are copied with the --preserve option. Make a backup of each existing destination file that would otherwise be overwritten or removed. The control parameter specifies what version control method to use; see version control for details.

Does cp automatically overwrite?

Usually, when you run a cp command, it overwrites the destination file(s) or directory as shown. To run cp in interactive mode so that it prompts you before overwriting an existing file or directory, use the -i flag as shown.

How do I force cp to overwrite without confirmation?

You can use cp -rf option to forcefully overwrite the destination file if already exists.


1 Answers

you can use back slash before cp

\cp -rf /from/directory/* to/directory
like image 126
jack Avatar answered Nov 11 '22 08:11

jack