Renaming Within the Current
Directory
The mv
command is a multi-purpose command that can be used to rename a
directory or move it to a different location. The command format below
shows two different formats for the mv
command depending on your goal. As with files, the mv
command has two basic formats used to rename and move directories.
Figure
shows the Move Old Name to New Name format which is used to
rename directories within the current directory.
Figure
demonstrates using the mv
command to rename a directory
within the current directory. In the example, the
cd
command changes to
your home directory and the
pwd
command verifies this. Next, the mkdir
command is used to create the maildir directory using a
relative pathname. The mv
command is then used to rename the maildir directory to
monthly.
Renaming in a Non-Current
Directory
This example uses the same command format as the prior one. Figure
demonstrates how to use the mv
command to rename a file in a
non-current directory. Here the mv
command is used to rename the
project subdirectory in the practice directory to project2 using a
relative pathname.
Moving a Directory and Its Contents
Figure
shows the command format to move a directory and its contents to
another directory or location in the directory tree. Figure
demonstrates using the mv
command to move the practice
directory from /home/user2 to the existing dir3 directory. When
moving a directory this way, if the target location exists, the source
directory will be copied into the target location. If the location
does not exist, the source directory will be renamed.
 |
|
Interactive
Media Activity
(Flash,
93 kB) |
| |
Renaming
and Moving Directories
In this media activity, you are logged in as user2 and your current working directory is: /home/user2/dir2. Refer to the Class File Tree Structure by clicking the 'tree' button located on the Menu Bar and type the commands that would accomplish the requested objectives.
Note: Be sure to press enter after each one. Click on step 1 to begin.
|
|
|
|
 |
 |
Lab
Activity
(Adobe
Acrobat Reader, 48 kB) |
| |
Renaming
and Moving Files and Directories
In
this lab, you will work with the versatile mv
(move) command to rename and move files as well as
directories. |
|
|
|
|