14

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?

capybaralet
  • 1,757
  • 3
  • 21
  • 31

2 Answers2

9

Use command mv to circumvent the alias and use --force if that doesn't stop mv from bothering you with questions (e.g., because of permissions).

yes | aCommand is the standard way to supply lots of y's to aCommand, but in this case that seems unnecessary.

Petr Skocik
  • 58,047
  • 6
  • 95
  • 142
  • 1
    So I can't do this "interactively", i.e. use mv -i and then once it starts prompting me, tell is "yes to all"? – capybaralet Oct 18 '15 at 21:58
  • 1
    This kind of thing is generally quite hard to do unless the program directly supports it (and I believe mv doesn't support this). Cancelling the action (Ctrl-C) and starting from scratch tends to be easier. – Petr Skocik Oct 18 '15 at 22:00
  • agree that you can't switch horses in the middle of the stream. Another solution like `command mv`, is to use the full path you the cmd. i.e. `/bin/mv files ...` when you want to skip the `-i` part. Good luck. – shellter Oct 19 '15 at 08:51
5

you can use back slash before cp

\cp -rf /from/directory/* to/directory
jack
  • 663
  • 1
  • 8
  • 11