sort.1 (2010 09)

s
sort(1) sort(1)
The following options override the default ordering rules:
-d Quasi-dictionary order: only alphanumeric characters and blanks (spaces and tabs), as
defined by LC_CTYPE are significant in comparisons (see environ (5)).
(UNIX Standard only, see standards (5)) The behavior is undefined for a sort key to
which -i or -n also applies.
-f Fold letters. Prior to being compared, all lowercase letters are effectively converted
into their uppercase equivalents, as defined by
LC_CTYPE.
-i In non-numeric comparisons, ignore all characters which are non-printable, as defined
by LC_CTYPE. For the ASCII character set, octal character codes 001 through 037 and
0177 are ignored.
-n The sort key is restricted to an initial numeric string consisting of optional blanks, an
optional minus sign, zero or more digits with optional radix character, and optional
thousands separators. The radix and thousands separator characters are defined by
LC_NUMERIC. The field is sorted by arithmetic value. An empty (missing) numeric
field is treated as arithmetic zero. Leading zeros and plus or minus signs on zeros do
not affect the ordering. The -n
option implies the -b option (see below).
-r Reverse the sense of comparisons.
-M Compare as months. The first several non-blank characters of the field are folded to
uppercase and compared with the langinfo (5) items ABMON_1 < ABMON_2 < ... <
ABMON_12. An invalid field is treated as being less than ABMON_1 string. For exam-
ple, American month names are compared such that JAN < FEB < ... < DEC.An
invalid field is treated as being less than all months. The -M option implies the -b
option (see below).
Field Separator Options
The treatment of field separators can be altered using the options:
-t char Use char as the field separator character; char is not considered to be part of a eld
(although it can be included in a sort key). Each occurrence of char is significant (for
example, <char ><char > delimits an empty field). If -t is not specified, <blank> char-
acters will be used as default field separators; each maximal sequence of <blank> char-
acters that follows a non-<blank> character is a field separator.
-b Ignore leading blanks when determining the starting and ending positions of a res-
tricted sort key. If the -b option is specified before the first -k
option (+pos1 argu-
ment), it is applied to all
-k options (+pos1 arguments). Otherwise, the -b option
can be attached independently to each
-k field_start or field_end option (+pos1 or (-
pos2 argument; see below). Note that the -b option is only effective when restricted
sort key specifications are given.
Restricted Sort Key
-k keydef The keydef argument defines a restricted sort key. The format of this definition is
field_start [ type ][,field_end [ type ]]
which defines a key field beginning at field_start and ending at field_end . The charac-
ters at positions field_start and field_end are included in the key field, providing that
field_end does not precede field_start . A missing field_end means the end of the line.
Fields and characters within fields are numbered starting with
1. Note that this is
different than the obsolete form of restricted sort keys, where numbering starts at 0.
See WARNINGS below.
Specifying field_start and field_end involves the notion of a field, a minimal sequence of
characters followed by a field separator or a new-line. By default, the first blank of a
sequence of blanks acts as the field separator. All blanks in a sequence of blanks are
considered to be part of the next field; for example, all blanks at the beginning of a line
are considered to be part of the first field.
The arguments field_start and field_end each have the form m
.n which are optionally
followed by one or more of the type options b, d, f, i, n, r,orM. These modifiers have
the functionality for this key only, that their command-line counterparts have for the
entire record.
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010