version 1.36, 2010/05/27 20:32:41 |
version 1.37, 2010/06/11 06:51:41 |
|
|
.Os |
.Os |
.Sh NAME |
.Sh NAME |
.Nm sort |
.Nm sort |
.Nd sort or merge text files |
.Nd sort, merge, or sequence check text files |
.Sh SYNOPSIS |
.Sh SYNOPSIS |
.Nm sort |
.Nm sort |
.Op Fl bCcdfHimnrsuz |
.Op Fl bCcdfHimnrsuz |
|
|
.Sh DESCRIPTION |
.Sh DESCRIPTION |
The |
The |
.Nm |
.Nm |
utility sorts text files by lines. |
utility sorts text files by lines, |
|
operating in one of three modes: sort, merge, or check. |
|
In sort mode, the specified files are combined and sorted |
|
by line. |
|
Merge mode is the same as sort mode except that the input |
|
files are assumed to be pre-sorted. |
|
In check mode, a single input file is checked to ensure that |
|
it is correctly sorted. |
|
.Pp |
Comparisons are based on one or more sort keys extracted |
Comparisons are based on one or more sort keys extracted |
from each line of input, and are performed lexicographically. |
from each line of input, and are performed lexicographically. |
By default, if keys are not given, |
By default, if keys are not given, |
|
|
.It Fl c |
.It Fl c |
Like |
Like |
.Fl C , |
.Fl C , |
but write a message to |
but additionally write a message to |
.Em stderr |
.Em stderr |
if the input file is not sorted. |
if the input file is not sorted. |
.It Fl m |
.It Fl m |
Merge only; the input files are assumed to be pre-sorted. |
Merge only; the input files are assumed to be pre-sorted. |
|
This option is overridden by the |
|
.Fl C |
|
or |
|
.Fl c |
|
options, |
|
if they are also present. |
.It Fl o Ar output |
.It Fl o Ar output |
The argument given is the name of an |
The argument given is the name of an |
.Ar output |
.Ar output |
|
|
.El |
.El |
.Pp |
.Pp |
The following options override the default ordering rules. |
The following options override the default ordering rules. |
When ordering options appear independent of key field |
If ordering options appear before the first |
specifications, the requested field ordering rules are |
.Fl k |
applied globally to all sort keys. |
option, they apply globally to all sort keys. |
When attached to a specific key (see |
When attached to a specific key (see |
.Fl k ) , |
.Fl k ) , |
the ordering options override |
the ordering options override |
all global ordering options for that key. |
all global ordering options for that key. |
|
Note that the ordering options intended to apply globally should not |
|
appear after |
|
.Fl k |
|
or results may be unexpected. |
.Bl -tag -width indent |
.Bl -tag -width indent |
.It Fl d |
.It Fl d |
Only blank space and alphanumeric characters |
Only blank space and alphanumeric characters |
|
|
argument of the |
argument of the |
.Fl k |
.Fl k |
option (see below). |
option (see below). |
Note that the |
Note that |
.Fl b |
.Fl b |
option has no effect unless key fields are specified. |
should not appear after |
.It Xo |
.Fl k , |
.Sm off |
and that it has no effect unless key fields are specified. |
.Fl k\ \& Ar field1 Op , Ar field2 |
|
.Sm on |
|
.Xc |
|
Designates the starting position, |
|
.Ar field1 , |
|
and optional ending position, |
|
.Ar field2 , |
|
of a key field. |
|
The |
|
.Fl k |
|
option may be specified multiple times, |
|
in which case subsequent keys are compared after earlier keys compare equal. |
|
The |
|
.Fl k |
|
option replaces the obsolescent options |
|
.Cm \(pl Ns Ar pos1 |
|
and |
|
.Fl Ns Ar pos2 . |
|
.It Fl R Ar char |
.It Fl R Ar char |
.Ar char |
.Ar char |
is used as the record separator character. |
is used as the record separator character. |
|
|
considered part of a field when determining key offsets. |
considered part of a field when determining key offsets. |
.It Fl z |
.It Fl z |
Uses the nul character as the record separator. |
Uses the nul character as the record separator. |
|
.El |
|
.Pp |
|
Sort keys are specified with: |
|
.Bl -tag -width indent |
|
.It Xo |
|
.Sm off |
|
.Fl k\ \& Ar field1 Op , Ar field2 |
|
.Sm on |
|
.Xc |
|
Designates the starting position, |
|
.Ar field1 , |
|
and optional ending position, |
|
.Ar field2 , |
|
of a key field. |
|
The |
|
.Fl k |
|
option may be specified multiple times, |
|
in which case subsequent keys are compared after earlier keys compare equal. |
|
The |
|
.Fl k |
|
option replaces the obsolescent options |
|
.Cm \(pl Ns Ar pos1 |
|
and |
|
.Fl Ns Ar pos2 . |
.El |
.El |
.Pp |
.Pp |
The following operands are available: |
The following operands are available: |