Difference between revisions of "Command Line Examples: mv"
From PHYSpedia
(Created page with "The mv command will do different things depending on how many arguments you give it. In the following examples, assume that we are in the directory <code>/home/user/work/example…") |
|||
Line 7: | Line 7: | ||
To "rename" file, just move it to a file with a different name | To "rename" file, just move it to a file with a different name | ||
<code> | <code> | ||
− | user@host:examples$ mv | + | user@host:examples$ mv file1.txt newname.txt |
</code> | </code> | ||
− | move | + | move a file to a subdirectory |
<code> | <code> | ||
− | user@host:examples$ mv | + | user@host:examples$ mv file1.txt finished/ |
+ | </code> | ||
+ | |||
+ | move two files to a subdirectory | ||
+ | <code> | ||
+ | user@host:examples$ mv file1.txt file2.txt finished/ | ||
+ | </code> | ||
+ | |||
+ | move all files ending with .txt to a subdirectory | ||
+ | <code> | ||
+ | user@host:examples$ mv *.txt finished/ | ||
</code> | </code> |
Revision as of 08:46, 7 February 2013
The mv command will do different things depending on how many arguments you give it.
In the following examples, assume that we are in the directory /home/user/work/examples
; there are two files named file1.txt
and file2.txt
; there is a sub-directory named finished
.
Note that these examples could not be run in order.
To "rename" file, just move it to a file with a different name
user@host:examples$ mv file1.txt newname.txt
move a file to a subdirectory
user@host:examples$ mv file1.txt finished/
move two files to a subdirectory
user@host:examples$ mv file1.txt file2.txt finished/
move all files ending with .txt to a subdirectory
user@host:examples$ mv *.txt finished/