

For that, assuming you use GNU mv, you may want to use mv with its -no-clobber (or -n) option, or possibly with its -backup (or -b) option. This does not prevent mv from overwriting existing files in the case where there might be a name collision. In the loop body, the current name will be stored in the name variable, and the mv simply renames the file by adding. This loops over all names that matches (a variant of) the filename globbing pattern that you mentioned (note, this is not a regular expression). In this case, we instead want to use mv with two arguments at a time, and for that we need to use a shell loop: for name in do

Assuming that this expands to more than two names, then the last argument needs to be the name of a directory for the command to be a valid mv command, or you'll get a "is not a directory" error. In your case, you use the expansion of * *.inp as the arguments, and this is going to expand to all the visible filenames in the current directory, followed by the names that matches *.inp. The issue with your command is that the mv command only can move/rename a single file (when given exactly two command line arguments), or move a bunch of files to a single destination directory (more than two command line arguments).
