mv or move Command (2024)

[ Previous |Next |Contents |Glossary |Home |Search ]AIX Version 4.3 Commands Reference, Volume 3

Purpose

Moves files.

Syntax

To Move Files to a Directory Maintaining Original File Names

{ mv | move } [ -i | -f ] SourceFile TargetFile

To Move and Rename a File or Directory

{ mv | move } [ -i | -f ] SourceFile ... TargetDirectory

Description

Attention: The mv (move) command can overwrite many existing files unless you specify the -i flag. The -i flag prompts you to confirm before it overwrites a file. If both the -f and -i flags are specified in combination, the last flag specified takes precedence.

The mv command moves files and directories from one directory to another, or renames a file or directory. If you move a file or directory to a new directory, it retains the base file name. When you move a file, all links to other files remain intact, except when you move it to a different file system. When you move a directory into an existing directory, the directory and its contents are added under the existing directory.

When you use the mv command to rename a file or directory, the TargetDirectory parameter can specify either a new file name or a new directory path name.

If moving the file would overwrite an existing file that does not have write-permission set and if standard input is a workstation, the mv command displays the file-permission code and reads a line from standard input. If that line begins with a y, or the locale's equivalent of a y, the mv command moves the file. If the response is anything other than a y, the mv command does nothing to that file and continues with the next specified file.

You can use the mv command to move files within the same file system or between file systems. Whether you are working in one file system or across file systems, the mv command copies the file to the target and deletes the original file. The mv command preserves in the new file the time of the most recent data modification, the time of the most recent access, the user ID, the group ID, and the file mode of the original file.

The mv command will modify either the source file or the destination path if the command is prematurely terminated.

Note: The mv command supports the -- (dash, dash) parameter as a delimiter that indicates the end of the flags.

Flags

Attention: The mv command can overwrite many existing files unless you specify the -i flag. The -i flag prompts you to confirm before it overwrites a file. If both the -f and -i flags are specified in combination, the last flag specified takes precedence.
-f Does not prompt you before overwriting an existing file.
-i Prompts you before moving a file or directory to an existing path name by displaying the name of the file followed by a question mark. If you answer with a line starting with y or the locale's equivalent of a y, the move continues. Any other reply prevents the move from occurring.

Examples

  1. To rename a file, enter:
    mv appendix apndx.a
    This command renames appendix to apndx.a. If a file named apndx.a already exists, its old contents are replaced with those of appendix.
  2. To move a directory, enter:
    mv book manual
    This command moves all files and directories under book to the directory named manual, if manual exists. Otherwise, the directory book is renamed manual.
  3. To move a file to another directory and give it a new name, enter:
    mv intro manual/chap1
    This command moves intro to manual/chap1. The name intro is removed from the current directory, and the same file appears as chap1 in the directory manual.
  4. To move a file to another directory, keeping the same name, enter:
    mv chap3 manual
    This command moves chap3 to manual/chap3
    Note: Examples 1 and 3 name two files, example 2 names two existing directories, and example 4 names a file and a directory.
  5. To move several files into another directory, enter:
    mv chap4 jim/chap5 /home/manual
    This command moves the chap4 file to the /home/manual/chap4 file directory and the jim/chap5 file to the /home/manual/chap5 file.
  6. To use the mv command with pattern-matching characters, enter:
    mv manual/* .
    This command moves all files in the manual directory into the current directory . (period), retaining the names they had in manual. This move also empties manual. You must type a space between the asterisk and the period.
    Note: Pattern-matching characters expand names of existing files only. For example, the command mv intro man*/chap1 does not work if the file manual/chap1 does not exist.

Exit Status

0 All input files were moved successfully.
>0 An error occurred.

Files

/usr/bin/mv Contains the mv command.
/usr/bin/move Contains the move command.

Related Information

The chmod command, ln command, rm command.

The rename subroutine.

Files Overview in the AIX Version 4.3 System User's Guide: Operating System and Devices.

Directory Overview in AIX Version 4.3 System User's Guide: Operating System and Devices.

Input and Output Redirection Overview in AIX Version 4.3 System User's Guide: Operating System and Devices.

[ Previous |Next |Contents |Glossary |Home |Search ]
mv or move Command (2024)

FAQs

What is the mv command for move? ›

Use the mv command to move files and directories from one directory to another or to rename a file or directory. If you move a file or directory to a new directory without specifying a new name, it retains its original name. Attention: The mv command can overwrite many existing files unless you specify the -i flag.

How do you overwrite without asking mv command? ›

This option stands for "force". The -f option allows you to overwrite any existing files with the same name as the file you are moving without being prompted.

What happens if I cancel the mv command? ›

Mv moves the file, then deletes the old copy - in that order. So if you cancel out, the copy that was being created is deleted and the original copy is retained.

Which is faster mv or cp? ›

On the same filesystem, 'mv' doesn't actually copy the data, it just remaps the inode, so it is far faster than cp. Rsync will be slower than cp since, it still needs to copy the entire file - and it has additional overhead (even if minor in this case).

How do I run an mv command? ›

The following are examples of how to use the mv command:
  1. To move a file to another directory and give it a new name, type the following: mv intro manual/chap1. This moves the intro file to the manual/chap1 directory. ...
  2. To move a file to another directory, keeping the same name, type the following: mv chap3 manual.

How do you use the move command? ›

To move a file or files, you specify the name and location of the file or files you want to move followed by the destination. The destination specifies the new location of the file, or the new name of the directory. The destination can consist of a drive letter followed by a colon, a directory name, or a combination.

How do I move files into another directory? ›

Select the item you want to move by holding down the right-mouse button (or the alternate mouse button if you're using the mouse with your left hand). Drag to the destination folder and release the mouse button.

Does the mv command delete files? ›

You can use the mv command to move files within the same file system or between file systems. Whether you are working in one file system or across file systems, the mv command copies the file to the target and deletes the original file.

How to force move a file in Linux? ›

Options Available in mv Command
  1. -i (interactive) The “-i” option makes the “mv” command ask for confirmation before overwriting an existing file. ...
  2. -f (Force) mv prompts for confirmation overwriting the destination file if a file is write-protected. ...
  3. -n (no-clobber) ...
  4. -b(backup) ...
  5. –version.
Apr 1, 2024

Does mv copy first? ›

When working across file systems, mv will only copy and then delete the original files, one by one.

How do you undo a move command? ›

To undo an action press Ctrl+Z on your keyboard, or select Undo on the Quick Access Toolbar. You can press Undo (or Ctrl+Z) repeatedly if you want to undo multiple steps.

What happens when mv fails? ›

Failures in the mv command are usually due to directory or file permissions and do not cause loss of data. Source directory is missing read permission: mv src/* dst fails to find any files. No data lost. Source directory is missing execute permission: mv src/a src/b dst fails to open either source.

Does mv copy files? ›

To copy directory dir1 with all the files and subdirectories to a different directory, issue “cp -r dir1 <path_to_new_dir>”. “mv” command is used to move or rename files and directories.

What is the difference between mv and move? ›

The mv command moves files and directories from one directory to another, or renames a file or directory. If you move a file or directory to a new directory, it retains the base file name. When you move a file, all links to other files remain intact, except when you move it to a different file system.

What is the difference between the cop and the mv command? ›

Key Distinctions:

When employing cp, the original file stays in its initial location, and a duplicate is generated in the destination. In contrast, with mv, the file is transferred to the destination, and no copy remains in the original location. mv is frequently employed for renaming files.

What is the move command in CMD? ›

In computing, move is a command in various command-line interpreters (shells) such as COMMAND.COM , cmd.exe , 4DOS/4NT, and PowerShell. It is used to move one or more files or directories from one place to another.

What is the shortcut key for move? ›

Keyboard shortcuts to select and move text in a document
ShortcutDescription
Ctrl+DownMove item in list or table one row down
Ctrl+UpMove item in list or table one row up
Ctrl+VPaste text or object
Ctrl+XCut selected text or object
15 more rows

What is the command for move in Autocad? ›

Command line: To start the Move tool from the command line, type “M” and press [Enter]. To move objects, select any objects you wish to move and press [Enter]. Two points need to be clicked, the move from point or base point and the move to point.

What is the shortcut for move code? ›

When you're in the flow, you want to re-arrange code fast. Use this tip to move code around without cut-and-paste. Move Statement Up with ⌘⇧↑ (macOS) / Ctrl+Shift+Up Arrow (Windows/Linux). Move Statement Down with ⌘⇧↑ (macOS) / Ctrl+Shift+Up Arrow (Windows/Linux).

Top Articles
Navigating Global Payments: Secure, Efficient, and Essential
Comment savoir si un site Web est sécurisé?
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Pearson Correlation Coefficient
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Tyson Zemlak

Last Updated:

Views: 6394

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Tyson Zemlak

Birthday: 1992-03-17

Address: Apt. 662 96191 Quigley Dam, Kubview, MA 42013

Phone: +441678032891

Job: Community-Services Orchestrator

Hobby: Coffee roasting, Calligraphy, Metalworking, Fashion, Vehicle restoration, Shopping, Photography

Introduction: My name is Tyson Zemlak, I am a excited, light, sparkling, super, open, fair, magnificent person who loves writing and wants to share my knowledge and understanding with you.