The shell expands wildcards (globs
) into the complete list of matching files before it executes the command. So the actual command that the shell ran was something like this:
mv mybackup.sql /home/user1/pub1/mybackup.sql /home/user1/pub2/mybackup.sql /home/user2/pub1/mybackup.sql ... ... /home/user100/pub100/mybackup.sql
With the whole list depending on how many files and directories are matched with * (Tack echo
to the front of the command to see what it looks like expanded).
Depending on how the final command is formatted, you can end up overwriting files of the same name, or moving whole directory trees to other places.
A safer way to use mv
in cases like this is to explicitly name the target directory with the -t
mv -t targetdir mybackup.sql
Also consider using the -v
(verbal) option, and either the -i
(interactive), or -n (no-clobber) options in mv
. Set them up as aliases or shell functions so they're always active by default.