Move Files In MacOSX Terminal

MacOSX Terminal provides commands to work with files. The mv command is used to move files in the MacOSX terminal. The mv command can be used to organize files and folders by moving them to related folders. The mv command cuts the provided files from their current location and pastes or moves to the specified destination.

Terminal mv Command Syntax

The mv command has very simple syntax which is like below.

mv SOURCE DESTINATION
  • SOURCE is the current file name or location.
  • DESTINATIPN is the destination or new file name and location.

Move File

The move command can be used to move files in the current working directory and related directories. In the following example we move the file named database.txt from the current working directory into the folder Downloads .

mv database.txt ./Downloads/

In the following example we move the file into the parent directory.

mv database.txt ../

In the following example we move the file with a new name to the folder named backup.

mv database.txt backup/mydatabase.txt

Move File with Absolute Path

The move operation can be completed by using absolute path. The absolute path is the complete path which is not related to the current working directory. In the following example we move the file named database.txt into the absolute path /var/db .

mv database.txt /var/db

Move File To User Home Directory

Another popular move operation in the terminal is moving files to the home directory of the user. The home directory of the user is expressed with the ~ sign and later path is added.

mv database.txt ~/backup

Leave a Comment