Is there a command or option that will allow me to move files without overwriting anything?
For the sake of argument, let us call the file foo.rar.
Now the -n sort of works, it won't overwrite the file. But if a file is there it also won't move the file. I want the file moved except for a system error like otu of disk space.
-b sort of works too. The problem with -b is that if there is a backup file, then -b will clobber the backup file with the new backup file.
So now to add a little meat to the question let us look at our example of foo.rar .Let us do a search for foo.rar in /home. We find 10 different files with that name. What I would like to do is execute the following three commands.
mkdir /tmp/foo_files
find /home -iname "foo.rar" -exec wanted_mv_command {} /tmp/foo_files \;
mv /tmp/foo_files ~/
I want ~/foo_files to contain something like: foo.rar, foo.rar.1, foo.rar.2 ... foo.rar.9 .
I don't care what pattern is used. Instead of foo.rar.# it could for example use foo.#.rar > I jsut want two things. That it indicates what the original name of the file was, and that it shows distinct versions of the file.
mv "/tmp/my file.txt" ~
(You can fix that by quoting your variables.) – Chris Davies Dec 19 '15 at 20:49