Copying directories (cp), Renaming directories (mv), Copying directories (cp) renaming directories (mv) – HP NonStop G-Series User Manual

Page 117: Directory copied into another directory

Advertising
background image

Copying Directories (cp)

You can use the cp command with the -r flag to copy directories and directory trees to another
part of the file system. The cp -r command has the following format:

cp -r source destination

The source entry is the name of the directory to be copied. The destination entry is the name
of the directory location to which you want to copy source.

Figure 7

shows how the cp -r command in the following example copies the directory tree

/reports

into the directory /project2. It is assumed that the command is entered from your

home directory.

$ cp -r reports project2

Figure 7 Directory Copied Into Another Directory

The /reports directory files file1, file2, file3, and notes, as well as the subdirectory
/status

, have been copied to /project2.

Renaming Directories (mv)

You can use the mv command to rename a directory only when that directory is contained in the
same disk partition. The mv command is also used to rename files.

Following is the general format of the mv command:

mv olddirectoryname newdirectoryname

The olddirectoryname entry is the name of the directory you wish to move or rename. The
newdirectoryname

entry is the new name you wish to assign to that directory.

In the following example, first change to the /reports directory. Then, enter the ls -i -d
command to list the inode-number for the /status directory (remember, your i-number may be
different from the example):

$ cd reports

$ ls -i -d status

1091 status

Now enter the mv command to change the name of /status to /newstatus. Then list the
i-number for the /newstatus directory:

$ mv status newstatus

$ ls -i -d newstatus

1091 newstatus

Notice that the second ls -i -d command does not list the original directory name /status.
It does list the new directory /newstatus, and it displays the same inode-number (1091 in this
example) for the new directory as for the original /status directory.

Copying Directories (cp)

117

Advertising
This manual is related to the following products: