Tips&Tricks

How to move files only if destination does not exist

terminal

Unix is simple and straight. It’s not ask you when you tell it to do something. For example, if you ask to move a file to the directory with same-named file… Unix will replace it without any words.

But we can ask Unix do it more “carefully”.

Merge one folder to another, but don’t override any existing files:

mv -n ./dir1/* ./dir2/

Take backup of destination file before overwriting existing file:

mv -bv ./dir1/* ./dir2/

-b is for backup,
-v is for verbose mode.