Technology – The Linux Move (mv) Command
The Linux move command (mv) is one of the essential commands, which can be very useful in Linux, Unix, and AIX. The primary purpose of the move command is obviously to move files, and of course, directories. The move command may also be used to rename files and to make backups.
Move Command Syntax
$ mv [options] source (file or directory) destination
Move Command options
option | description |
mv -f | force move by overwriting destination file without prompt |
mv -i | interactive prompt before overwriting |
mv -u | update – move when the source is newer than the destination |
mv -v | verbose – print source and destination files |
MV – t | explicitly saying to move the file or directory here, rather trying to fit everything into the last argument. |
mv * | Move all (Multiple) files to a specific director without listing by name |
For More move command details see the Linux documentation manuals using the man command
$ man mv
mv command examples
Here are some quick and very simple move command (MV) examples for reference.
Move Move to files to the /Archive/ directory:
$ mv happy.txt garden.txt /Archive/
Move all “.txt” files in the current directory to subdirectory backup:
$ mv *.txt backup
Move all files in subdirectory ‘backup’ to current directory:
$ mv backup/*
Rename file happy.txt to happy.bak filename:
$ mv happy.txt happy.bak
Rename directory backup to backup2:
$ mv backup backup2
Update – move when happy.txt is newer or missing in target directory:
$ mv -u happy.txt backup
Move happy.txt and prompt before overwrite backup / happy.txt:
$ mv -v happy.txt backup
One thought on “Technology – The Linux Move (mv) Command”