z/OS UNIX System Services User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Copying files within the z/OS UNIX file system

z/OS UNIX System Services User's Guide
SA23-2279-00

You can use the shell commands cp or pax or the TSO/E command OCOPY to copy files within the z/OS UNIX file system.

Using the shell: Use the cp shell command to copy:
  • One file to another file in the working directory, or to a new file in another directory.
  • A file, a set of files, or a set of directories to another location in your file system.
To copy one file to another file in the working directory, enter:
cp file1 file2
This command copies the contents of file1 into file2.
To copy a list of files into another directory, enter:
cp file1 file2 file3 dir1
This command copies the files file1, file2, file3 into the directory dir1.

For further information about the cp command, see z/OS UNIX System Services Command Reference.

You can use the pax shell command in copy mode to copy a set of directories and files to another place in your file system.

To use pax in copy mode, specify the -r and -w (or -rw) options, as follows:
pax -rw pathname directory
pax reads the specified path name and copies it to the target directory. The target directory must already exist and you must have write access to it. If a path name is a directory, pax copies all the files and subdirectories in that directory, as well as the directory itself, to the target directory.

Using pax in copy mode with additional options such as -C and -M can be useful for migrating data from one file system type to another (for instance, from HFS to zFS). For further information about the pax command, see the pax command description in z/OS UNIX System Services Command Reference.

Using TSO/E: You can use the TSO/E OCOPY command to copy a z/OS UNIX file to another z/OS UNIX file and, in the process, convert the data from one code page to another.

Example: To copy a z/OS UNIX file to another z/OS UNIX file in a different directory, converting the data:
ALLOCATE DDNAME(KPAYR) PATH('/u/kinn/bin/payroll')
ALLOCATE DDNAME(MPAYR) PATH('/u/mills/bin/payroll')
OCOPY INDD(KPAYR) OUTDD(mpayr) TEXT CONVERT((BPXFX311)) TO1047

The combination of CONVERT((BPXFX311)) and TO1047 indicates that you want to use the ASCII conversion table to convert from ASCII to code page IBM-1047. TO1047 or FROM1047 is required if CONVERT is specified.

With the CONVERT parameter, you can specify a data set name, a member name, or both. In this example, the use of (( )) with no data set name indicates that you are specifying a member that is a module in the standard search order for MVS™.

If the files that are being allocated are new files, the PATHOPTS and PATHMODE operands are required.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014