Files
git.softwareshinobi.com/docs/Linux-Commands/Working-With-Files/032-the-mv-command.md
Software Shinobi ba2080733d
All checks were successful
learn org at code.softwareshinobi.com/git.softwareshinobi.com/pipeline/head This commit looks good
automated terminal push
2025-06-04 20:15:25 -04:00

2.1 KiB
Executable File

The mv command

The mv command lets you move one or more files or directories from one place to another in a file system like UNIX. It can be used for two distinct functions:

  • To rename a file or folder.
  • To move a group of files to a different directory.

Note: No additional space is consumed on a disk during renaming, and the mv command doesn't provide a prompt for confirmation

Syntax:

mv [options] source (file or directory)  destination

Examples:

  1. To rename a file called old_name.txt:
mv old_name.txt new_name.txt
  1. To move a file called essay.txt from the current directory to a directory called assignments and rename it essay1.txt:
mv essay.txt assignments/essay1.txt
  1. To move a file called essay.txt from the current directory to a directory called assignments without renaming it
mv essay.txt assignments

Additional Flags and their Functionalities:

Short Flag Long Flag Description
-f --force Force move by overwriting destination file without prompt
-i --interactive Interactive prompt before overwrite
-u --update Move only when the source file is newer than the destination file or when the destination file is missing
-n --no-clobber Do not overwrite an existing file
-v --verbose Print source and destination files
-b --backup Create a Backup of Existing Destination File