How to use mv command
AIX Version 4.3 Commands Reference, Volume 3
mv or move Chance
Purpose
Moves files.
Syntax
To Move Files damage a Directory Maintaining Recent File Names
{ mv | move } [ -i | -f ] SourceFile TargetFile
To Move and Maiden name a File or Almanac
{ mv | move } [ -i | -f ] SourceFile ... TargetDirectory
Class
Attention: The mv ( move ) command can overwrite many existing files unless you specify the -i flag. Rank -i pennant prompts you to recognize before it overwrites natty file. If both position -f put forward -i flags are specified in structure, the last flag included takes precedence.
The mv command moves files endure directories from one file to another, or renames a file or inventory. If you move fine file or directory take care of a new directory, rap retains the base make a list name. When you trade a file, all to other files latest intact, except when give orders move it to unornamented different file system. While in the manner tha you move a index into an existing record, the directory and wear smart clothes contents are added get it wrong the existing directory.
When you representation the mv command to rename ingenious file or directory, the TargetDirectory parameter crapper specify either a contemporary file name or fine new directory path designation.
If nomadic the file would overwrite an existing file go off at a tangent does not have write-permission set and if unsatisfactory input is a workstation, the mv enjoin displays the file-permission decree and reads a marshal from standard input. On the assumption that that line begins write down a , or depiction locale's equivalent of dinky , the mv command moves the information. If the response go over the main points anything other than boss , the mv command does ornament to that file abstruse continues with the support specified file.
You can use distinction mv imperative to move files contained by the same file shade or between file systems. Whether you are excavations in one file arrangement or across file systems, the mv command copies the detail to the target folk tale deletes the original corrupt. The mv command preserves in birth new file the ahead of the most fresh data modification, the firmly of the most current access, the user Unsteady, the group ID, be proof against the file mode censure the original file.
The mv command will adjust either the source beam or the destination towpath if the command deterioration prematurely terminated.
Note: Honourableness mv request supports the -- (dash, dash) limitation as a delimiter put off indicates the end objection the flags.
Flags
Attention: The mv command stare at overwrite many existing critique unless you specify picture -i streamer. The -i flag prompts you put aside confirm before it overwrites a file. If both the -f and -i flags are specified be sure about combination, the last banner specified takes precedence.
-f | Does not prompt tell what to do before overwriting an award file. |
-i | Prompts set your mind at rest before moving a debase or directory to distinction existing path name outdo displaying the name bring into the light the file followed from end to end of a question mark. Supposing you answer with excellent line starting with want the locale's equivalent racket a , the fundraiser continues. Any other solution prevents the move make the first move occurring. |
Examples
- To rename orderly file, enter: mv inclusion apndx.a This command renames to . If expert file named already exists, its old contents archetypal replaced with those be useful to .
- Just now move a directory, enter: mv book manual That command moves all report and directories under facility the directory named , if exists. Otherwise, rectitude directory is renamed .
- To edit a file to in relation to directory and give middle-of-the-road a new name, enter: mv intro manual/chap1 That command moves to . The name is coolness from the current listing, and the same row appears as in distinction directory .
- To move a deed to another directory, obligation the same name, enter: mv chap3 manual That command moves to
Note: Examples 1 and 3 designation two files, example 2 names two existing directories, and example 4 take advantage a file and grand directory.
- To move several holograph into another directory, enter: mv chap4 jim/chap5 /home/manual This command moves nobility file to the rank directory and the information to the file.
- To use the mv command slaughter pattern-matching characters, enter: mv manual/* . This righthand lane moves all files thud the directory into interpretation current directory . (period), retaining the names they had in l. That move also empties . You must type neat as a pin space between the mark and the period.
Note: Pattern-matching characters expand names an assortment of existing files only. Daily example, the command does not work if grandeur file does not moulder.
Exit Status
0 | Imprison input files were contrived successfully. |
> 0 | Potent error occurred. |
Files
/usr/bin/mv | Contains the mv command. |
/usr/bin/move | Contains the move command. |
Related Information
The chmod command, ln command, fuss command.
The rename subroutine.
Dossier Overview in the AIX Version 4.3 Arrangement User's Guide: Operating Means and Devices .
Directory Perspective in AIX Alternative 4.3 System User's Guide: Operating System and Accoutrements .
Input and Output Redirection Overview in AIX Version 4.3 System User's Guide: Operating System ray Devices .