content









Content









7.1
Advanced Directory
and File Management Using the Command Line




7.1.4
Renaming
and moving files




Renaming a file in the Current
Directory Files and directories can be renamed and
moved using the same multipurpose
mv (move) command. There is no
renaming command in UNIX.
The command format in Figure

shows the syntax to rename a file in the same directory. This format
changes the name of the source, the old filename, to a target
filename, the new filename, in the same directory. This version can be
thought of as moving from old to new in the same directory. 
Figure

shows renaming a file using this format. Note that in Figure
,
the interactive option (-i) is also available with the

mv

command. The

mv -i option prompts for confirmation whenever the move would
overwrite an existing target file. An answer of y means that the move
should proceed. Any keystroke other than y prevents
mv
from
overwriting the target file. The
mv command changes the name of the
original file, whereas the cp command copies a file and gives it a new
name, leaving the original file intact.
Moving a File to Another
Directory 
To move a file to a different
directory, use the format in Figure
.
This format moves the source file or files to a new target directory.
The student can add a slash and a filename after the destination
directory to give the file a different name, if desired. This format
moves the source, what to move, to a target directory name, where to
move. This version can be thought of as moving from what to where in
the same directory. 
Figure

shows moving a file to another directory using this format. The
example shows moving the brands file from the coffees subdirectory to
the home directory using the tilde (~) shortcut.




















Interactive
Media Activity
(Flash,
93 kB)




 

Renaming
and Moving Files
In
this media activity, the students are logged in
as user2 and their current working directory is:
/home/user2/dir2. Refer to the Class File Tree
Structure by clicking the 'tree' button located
on the Menu Bar. Type the commands that would
accomplish the requested objectives. 
Note:
Be sure to press enter after each one. Click on
step 1 to begin.

























Wyszukiwarka

Podobne podstrony:
content
content
content
content
content
content
content
content
content
function domnode get content
content
content
content
content
content
content

więcej podobnych podstron