mv

move aka rename a file or directory

mv [option][-T] source dest
mv [option]source… directory
mv [option]… -t directory source…

Rename source to dest Or move source(s) to directory.

If source is on a different file system than dest it is copied and then the original is deleted.
This requires write permission to the source !

-u
--update
only when the source is newer than the dest.
specifing more than one of -i, -f, -n, only the final one takes effect.
-i
--interactive
prompt before overwrite
-f
--force
do not prompt before overwriting
-n
--no-clobber
do not overwrite an existing file
-b rename destinations first using ~ suffix.
-backup[=control]
control option or through $VERSION_CONTROL
none
off
Don't make backups (even with --backup )
numbered
t
numbered backups
existing
nil
numbered if numbered backups exist, simple otherwise
simple
never
always make simple backups
-S
--suffix=suffix
override the default backup suffix ,~,
unless set with --suffix or $SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via --backup
-strip-trailing-slashes remove trailing slashes from sources.
-T
--no-target-directory
treat dest as a normal file
-t
--target-directory=directory
all sources to directory
-v
--verbose
display what is happening
-Z
--context
set SELinux security context of destination file to default type
-help display this help and exit
-version output version information and exit

Failing example:

ls -l software/archive
total 0

ls -R software
software 
software/ImInSoftware.txt
software/IBM/mvs.txt
software/cisco/version7.txt

mv -v software/*  archive 

software/ImInSoftware.txt     is moved
software/IBM/mvs.txt          not moved; directory IBM does not exist
software/cisco/version7.txt   not moved; directory cisco does not exist

Permission and FileFlag Errors

/Volumes/vacation/2023/scotland > ls -lO   # Display file flags like nochg 
total 152
-rwxr--r--  1 nochg dgerman staff  152657 Jun 30  2022 P1180414.JPG

> mv P1180414.JPG xyz
mv: rename P1180414.JPG to xyz: Operation not permitted
mv: fastcopy: open() failed (to): /Users/P1180414.JPG: Permission denied

> rm P1180414.JPG                                         
override rwxr--r-- dgerman/staff uchg for P1180414.JPG?  nochg  is set!

> mv 00 s132_nrf52
mv: rename 00 to s132_nrf52/00: Permission denied
ls -l s132_nrf52
dr-xr--r--  2 dgerman  staff    64 Feb 17 18:35 s132_nrf52/   Target directory is not writable.

cp: /Users/dgerman/LibraryF/Application Support: unable to copy extended attributes to ./LibraryF/Application Support: Permission denied


When moving to a different volume, mv resorts to copying the files to the destionation. When the copy is complete mv removes the source , Unless the copy terminated non-zero status mv: /bin/cp source destination source destination terminated with 1 (non-zero) status In this case the source is NOT removed!