Previous Topic: ldifdelta Tool—Calculate the Difference Between LDIF Files

Next Topic: Reasons for BAD Records

ldifsort Tool—Sort LDIF Records

Use the ldifsort tool to sort an LDIF file or input stream for the given attribute type.

The tool can sort the LDIF record based on any attribute. By default, the ldifsort tool sorts LDIF records based on their distinguished names. This ensures that each record is followed by its immediate subordinates.

You may opt to sort in descending order. You can use this option, for example, when deleting the entries in an LDIF file from the directory. This sorts the LDIF file on DN in descending order, thus ordering subordinates before superior entries. The LDIF file can then be passed to dxmodify to delete these entries.

Although the default sort is by DN, you may wish to use another attribute, for example, to sort employee records in an LDIF file based on their employee numbers for administration, or based on telephone numbers to allocate spare lines.

The ldifsort tool can cope with bad input records. See the -b option. A record is bad for one of the following reasons:

This command has the following format:

ldifsort [options] infile [outfile]
options

Denotes one or more of the following options:

-a attr

Sorts entries based on the specified attribute. The default sort attribute is dn.

-b file

Writes bad input records to the specified file. Each bad input record is accompanied by the reason it is considered bad.

If -b is not specified, bad records are silently discarded, except that the final summary report gives the count of bad input records.

-d

Sorts in descending order. The default is to sort in ascending order.

-m count

Specifies the number of records that are put into each sorting bucket. The default is 200. For the fastest sort time, set this option to the square root of the number of entries in the file (-m count = Ö number of entries in file).

-r block

Specifies the number of sorting buckets to allocate at a time. The default is 10,000.

-s bytes

Specifies the size of read buffer for each bucket. The default is 2,048 bytes.

-t dir

Specifies the directory to use for temporary files.

-u

(Default). Checks for duplicates. Duplicate records are considered bad input records.

-U

Does not check for duplicates, so duplicates are considered good input records.

-v

Runs in verbose mode. In this mode, diagnostics are sent to standard error.

infile

Specifies the file to be sorted.

outfile

Specifies the file to which output is to be written. The default output is standard out.

Example: Make Directories the Same

This example makes the old directory the same as the reference directory:

dxsearch -L -h oldhost "(oc=*)" > old.ldif
dxsearch -L -h referencehost "(oc=*)" > ref.ldif
ldifsort old.ldif old_sorted.ldif
ldifsort ref.ldif ref_sorted.ldif
ldifdelta old_sorted.ldif ref_sorted.ldif | dxmodify -h oldhost