Copying a keyed file

kfcopy

Copy a keyed file


SYNTAX

kfcopy [-bcdehilsv][-F tempfile] oldfile newfile

Copies all the undeleted records in oldfile to newfile, which may be an existing file or a new, empty file. All secondary indexes are automatically copied as well.

The main uses of kfcopy are:

  1. Data archiving The kfcopy program is frequently used to archive records to a file in another directory or on another file system. In this case newfile is often an already existing file containing previously archived records. The -e switch should be used to preserve records already existing in newfile.

  2. Reducing disk storage space The kfcopy program is the optimal way of reducing the amount of disk storage used by a file which has undergone permanent and substantial deletions. The space occupied by deleted records is preserved, and reused for newly inserted records. If it is not expected that records will be inserted to replace the deleted ones, the space is wasted. Using kfcopy enables a file to be reduced to its minimum size, removing the space occupied by the deleted records.

oldfile, newfile

oldfile is the name of the source file from which records are to be copied. newfile is the name of the destination file. No file extension should be specified for oldfile or newfile.

The destination file may already exist, and may or may not contain records. The -e option must be used if records in newfile are to be preserved. In this case, newfile must have an identical key and record structure to oldfile. This means that every single field must match in terms of type, size and position in the record layout, though the field names need not be the same. If the structure differs, kfcopy proceeds without warning but newfile will be damaged.

If oldfile and newfile bear the same name, they must be situated in different directories or on different file systems. The file name of at least one of them must include a specification of the path or file system.

If they bear different names, they may be situated in the same directory, and as long as kfcopy is run from this directory no pathnames are necessary.

[-cdehilv]
-F tempfile

Command line options.


Command line options

-b, -s

Files may be big or standard, and by default kfcopy creates the new file in the same format as the old one. The -b flag forces the new file to be a big file, while -s forces a standard file. See Maximum number of records; creating big files.

-c

Displays a count every 1000 records copied.

-d

Tells kfcopy to create a data file even if old file is index-only.

-e

Indicates to kfcopy that the destination file newfile already exists. It may or may not contain records. Any existing records in newfile are preserved, and all valid records (those with unique keys) from oldfile are inserted into newfile. If a record is found in oldfile whose key exactly matches that of a record already existing in newfile, the record is not inserted. The number of duplicate keys which have been encountered and ignored in this way is reported at the end of the kfcopy operation. This switch is useful for archiving records to a file already containing previously archived records. Note that if newfile already exists and the -e option is not used, any existing records in newfile will be destroyed.

-h

Display a help screen listing these options. No other action is taken.

-F tempfile

Places all messages that would normally be displayed on the terminal in the named file and suppresses all questions.

-i

Create an index-only file if the key length and record length are the same. If both -i and -d are specified, -i takes precedence.

-l

Turn transaction logging off. Unless this option is used, kfcopy updates the transaction log file if it is present in the directory $SCULPTOR/recover.

-v

Outputs version information. No other action is taken.


Error messages

Can’t open filename (operating system error number nnn)

The named file could not be opened, due to the operating system error with the number specified. Check your operating system manual for further details. Frequent causes of this event are incorrect access permissions and file not found.


x: Option unknown

The option -x is not valid for kfcopy. Check the Options section above for valid options.


Interrupt!

The kfcopy process was interrupted and newfile is not complete.


EXAMPLES

  1. Copy contents of a file to an existing archive file, preserving the archive file contents:

    kfcopy -e numbers \archive\numbers
    
  2. Copy a file to a new, empty file in the current working directory:

    kfcopy oldfile newfile
    

RELATED TOPICS

Keyed file utilities

Sculptor keyed files

Data dictionary editor

newkf

kfri