.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\" This code is derived from software contributed to Berkeley by
.\" the Institute of Electrical and Electronics Engineers, Inc.
.\" %sccs.include.redist.roff%
.\" @(#)sort.1 8.1 (Berkeley) %G%
.Nd sort or merge text files
sorts text files by lines.
Comparisons are based on one or more sort keys (or fields) extracted
from each line of input, and are performed
lexicographically. By default, if keys are not given,
regards each input line as a single field.
The following options are available:
Check that the single input file is sorted lexicographically.
If the file is not sorted,
sorts it and writes the sorted output to the standard output or the
filename specified by the
Merge only; the input files are assumed to be pre-sorted.
The argument given is the name of an
be used instead of the standard output.
can be the same as one of the input files.
is used for creating temporary files.
Unique: suppress all but one in each set of lines
check that there are no lines with duplicate keys.
The following options override the default ordering rules.
When ordering options appear independent of key field
specifications, the requested field ordering rules are
applied globally to all sort keys.
.\" the specified ordering options override
.\" all global ordering options for that key.
Only blank space and alphanumeric characters
.\" to the current setting of LC_CTYPE
Considers all lowercase characters that have uppercase
equivalents to be the same for purposes of
Ignore all non-printable characters.
An initial numeric string, consisting of optional
blank space, optional minus sign, and zero or more
digits (including decimal point)
.\" optional radix character and thousands
.\" (as defined in the current locale),
is sorted by arithmetic value.
is only effective when key fields have been specified
is considered equal to zero.
Reverse the sense of comparisons.
The treatment of field separators can be altered using the
Leading blank spaces are ignored when determining the starting
ending positions of a restricted sort key.
option is specified before the first
argument, it shall be applied to all
attached independently to each
is used as the field separator character;
is not considered to be part of a field (although it
can be included in a sort key).
is significant (for example,
delimits an empty field).
blank space characters are used as default field
Designates the start position of a key field.
Designates the end position of a key field.
The following operands are available:
The pathname of a file to be sorted, merged, or checked.
operands are specified, or if
the standard input is used.
defined as a minimal sequence of characters followed by a
field separator or a newline character.
blank space of a sequence of blank spaces acts as the field separator.
All blank spaces in a sequence of blank spaces are considered
to be part of the next field; for example, all blank spaces at
the beginning of a line are considered to be part of the
argument defaults to the beginning of a line.
argument defaults to the end of a line.
followed by one or more of the options
indicating the first character of the
is counted from the first
non-blank character in the
non-blank character in the
character (including separators) after the last
the last character of the
is counted from the last leading blank character in
refers to the first non-blank character in the
.Bl -tag -width Pa -compact
.It Pa /var/tmp/stm*, /tmp/*
Default temporary directories (in order of search).
Lines which are longer than 4096 are discarded and processing continues.