Renaming files, Moving files into another directory, Renaming files moving files into another directory – HP NonStop G-Series User Manual

Page 103

Advertising
background image

NOTE:

For the following RVUs, the mv command fails with error “Guardian or User Defined Error

197” if a remote user attempts to move an SQL object that is in the OSS file system and the file is
present in the destination directory.

All G-series RVUs

H-series RVUs prior to H06.23

J-series RVUs prior to J06.12

To move this type of file on systems running the above RVUs, a local user must execute the mv
command.

Renaming Files

You can use the mv command to rename files.

In the following example, first list the inode-number of each file in your current directory with the
ls -i

command. Then enter the mv command to change the name of file file2x to newfile.

(The inode-numbers displayed on your screen will differ from the numbers in this example. For
more information about inode-numbers, see

“How Links Work—Understanding Filenames and

inode-numbers” (page 109)

.)

$ ls -i

1077 file1 1088 file2x 1080 project

1078 file2 1079 file3 1085 reports

$ mv file2x newfile

Now list the contents of the directory once again:

$ ls -i

1077 file1 1079 file3 1080 project

1078 file2 1088 newfile 1085 reports

Note two things in this example:

The mv command changes the name of file file2x to newfile.

The inode-number for the original file (file2x) and newfile is the same: 1088.

The mv command removes the connection between inode-number 1088 and filename file2x,
replacing it with a connection between inode-number 1088 and filename newfile. However,
the command does not change the file itself.

Moving Files Into Another Directory

You can also use the mv command to move one or more files from your current directory into a
different directory.

Type the target directory name carefully, because the mv command does not distinguish between
filenames and directory names. If you enter an invalid directory name, the mv command simply
takes that name as a new filename. The result is that the file is renamed rather than moved.

In the following example, the ls command lists the contents of your home directory. Then, the mv
command moves file2 from your current directory into the /reports directory. The ls command
then verifies that the file has been removed:

$ ls

file1 file2 file3 newfile project reports

$ mv file2 reports

Renaming and Moving Files (mv) 103

Advertising
This manual is related to the following products: