1*84d9c625SLionel Sambuc.\" $NetBSD: sort.1,v 1.34 2013/05/29 15:00:35 wiz Exp $ 20fbbaa43SLionel Sambuc.\" 30fbbaa43SLionel Sambuc.\" Copyright (c) 2000-2003 The NetBSD Foundation, Inc. 40fbbaa43SLionel Sambuc.\" All rights reserved. 50fbbaa43SLionel Sambuc.\" 60fbbaa43SLionel Sambuc.\" This code is derived from software contributed to The NetBSD Foundation 70fbbaa43SLionel Sambuc.\" by Ben Harris and Jaromir Dolecek. 80fbbaa43SLionel Sambuc.\" 90fbbaa43SLionel Sambuc.\" Redistribution and use in source and binary forms, with or without 100fbbaa43SLionel Sambuc.\" modification, are permitted provided that the following conditions 110fbbaa43SLionel Sambuc.\" are met: 120fbbaa43SLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright 130fbbaa43SLionel Sambuc.\" notice, this list of conditions and the following disclaimer. 140fbbaa43SLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright 150fbbaa43SLionel Sambuc.\" notice, this list of conditions and the following disclaimer in the 160fbbaa43SLionel Sambuc.\" documentation and/or other materials provided with the distribution. 170fbbaa43SLionel Sambuc.\" 180fbbaa43SLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 190fbbaa43SLionel Sambuc.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 200fbbaa43SLionel Sambuc.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 210fbbaa43SLionel Sambuc.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 220fbbaa43SLionel Sambuc.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 230fbbaa43SLionel Sambuc.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 240fbbaa43SLionel Sambuc.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 250fbbaa43SLionel Sambuc.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 260fbbaa43SLionel Sambuc.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 270fbbaa43SLionel Sambuc.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 280fbbaa43SLionel Sambuc.\" POSSIBILITY OF SUCH DAMAGE. 290fbbaa43SLionel Sambuc.\" 300fbbaa43SLionel Sambuc.\" Copyright (c) 1991, 1993 310fbbaa43SLionel Sambuc.\" The Regents of the University of California. All rights reserved. 320fbbaa43SLionel Sambuc.\" 330fbbaa43SLionel Sambuc.\" This code is derived from software contributed to Berkeley by 340fbbaa43SLionel Sambuc.\" the Institute of Electrical and Electronics Engineers, Inc. 350fbbaa43SLionel Sambuc.\" 360fbbaa43SLionel Sambuc.\" Redistribution and use in source and binary forms, with or without 370fbbaa43SLionel Sambuc.\" modification, are permitted provided that the following conditions 380fbbaa43SLionel Sambuc.\" are met: 390fbbaa43SLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright 400fbbaa43SLionel Sambuc.\" notice, this list of conditions and the following disclaimer. 410fbbaa43SLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright 420fbbaa43SLionel Sambuc.\" notice, this list of conditions and the following disclaimer in the 430fbbaa43SLionel Sambuc.\" documentation and/or other materials provided with the distribution. 440fbbaa43SLionel Sambuc.\" 3. Neither the name of the University nor the names of its contributors 450fbbaa43SLionel Sambuc.\" may be used to endorse or promote products derived from this software 460fbbaa43SLionel Sambuc.\" without specific prior written permission. 470fbbaa43SLionel Sambuc.\" 480fbbaa43SLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 490fbbaa43SLionel Sambuc.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 500fbbaa43SLionel Sambuc.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 510fbbaa43SLionel Sambuc.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 520fbbaa43SLionel Sambuc.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 530fbbaa43SLionel Sambuc.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 540fbbaa43SLionel Sambuc.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 550fbbaa43SLionel Sambuc.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 560fbbaa43SLionel Sambuc.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 570fbbaa43SLionel Sambuc.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 580fbbaa43SLionel Sambuc.\" SUCH DAMAGE. 590fbbaa43SLionel Sambuc.\" 600fbbaa43SLionel Sambuc.\" @(#)sort.1 8.1 (Berkeley) 6/6/93 610fbbaa43SLionel Sambuc.\" 62*84d9c625SLionel Sambuc.Dd May 29, 2013 630fbbaa43SLionel Sambuc.Dt SORT 1 640fbbaa43SLionel Sambuc.Os 650fbbaa43SLionel Sambuc.Sh NAME 660fbbaa43SLionel Sambuc.Nm sort 670fbbaa43SLionel Sambuc.Nd sort or merge text files 680fbbaa43SLionel Sambuc.Sh SYNOPSIS 69*84d9c625SLionel Sambuc.Nm 700fbbaa43SLionel Sambuc.Op Fl bcdfHilmnrSsu 710fbbaa43SLionel Sambuc.Oo 720fbbaa43SLionel Sambuc.Fl k 730fbbaa43SLionel Sambuc.Ar field1 Ns Op Li \&, Ns Ar field2 740fbbaa43SLionel Sambuc.Oc 750fbbaa43SLionel Sambuc.Op Fl o Ar output 760fbbaa43SLionel Sambuc.Op Fl R Ar char 770fbbaa43SLionel Sambuc.Op Fl T Ar dir 780fbbaa43SLionel Sambuc.Op Fl t Ar char 790fbbaa43SLionel Sambuc.Op Ar 800fbbaa43SLionel Sambuc.Sh DESCRIPTION 810fbbaa43SLionel SambucThe 820fbbaa43SLionel Sambuc.Nm 830fbbaa43SLionel Sambucutility sorts text files by lines. 840fbbaa43SLionel SambucComparisons are based on one or more sort keys extracted 850fbbaa43SLionel Sambucfrom each line of input, and are performed lexicographically. 860fbbaa43SLionel SambucBy default, if keys are not given, 870fbbaa43SLionel Sambuc.Nm 880fbbaa43SLionel Sambucregards each input line as a single field. 890fbbaa43SLionel Sambuc.Pp 900fbbaa43SLionel SambucThe following options are available: 910fbbaa43SLionel Sambuc.Bl -tag -width Fl 920fbbaa43SLionel Sambuc.It Fl c 930fbbaa43SLionel SambucCheck that the single input file is sorted. 940fbbaa43SLionel SambucIf the file is not sorted, 950fbbaa43SLionel Sambuc.Nm 960fbbaa43SLionel Sambucproduces the appropriate error messages and exits with code 1; otherwise, 970fbbaa43SLionel Sambuc.Nm 980fbbaa43SLionel Sambucreturns 0. 990fbbaa43SLionel Sambuc.Nm 1000fbbaa43SLionel Sambuc.Fl c 1010fbbaa43SLionel Sambucproduces no output. 102*84d9c625SLionel SambucSee also 103*84d9c625SLionel Sambuc.Fl u . 1040fbbaa43SLionel Sambuc.It Fl H 1050fbbaa43SLionel SambucIgnored for compatibility with earlier versions of 1060fbbaa43SLionel Sambuc.Nm . 1070fbbaa43SLionel Sambuc.It Fl m 1080fbbaa43SLionel SambucMerge only; the input files are assumed to be pre-sorted. 1090fbbaa43SLionel Sambuc.It Fl o Ar output 1100fbbaa43SLionel SambucThe argument given is the name of an 1110fbbaa43SLionel Sambuc.Ar output 1120fbbaa43SLionel Sambucfile to be used instead of the standard output. 1130fbbaa43SLionel SambucThis file can be the same as one of the input files. 1140fbbaa43SLionel Sambuc.It Fl S 1150fbbaa43SLionel SambucDon't use stable sort. 1160fbbaa43SLionel SambucDefault is to use stable sort. 1170fbbaa43SLionel Sambuc.It Fl s 1180fbbaa43SLionel SambucUse stable sort, keeps records with equal keys in their original order. 1190fbbaa43SLionel SambucThis is the default. 1200fbbaa43SLionel SambucProvided for compatibility with other 1210fbbaa43SLionel Sambuc.Nm 1220fbbaa43SLionel Sambucimplementations only. 1230fbbaa43SLionel Sambuc.It Fl T Ar dir 1240fbbaa43SLionel SambucUse 1250fbbaa43SLionel Sambuc.Ar dir 1260fbbaa43SLionel Sambucas the directory for temporary files. 1270fbbaa43SLionel SambucThe default is the value specified in the environment variable 1280fbbaa43SLionel Sambuc.Ev TMPDIR or 1290fbbaa43SLionel Sambuc.Pa /tmp 1300fbbaa43SLionel Sambucif 1310fbbaa43SLionel Sambuc.Ev TMPDIR 1320fbbaa43SLionel Sambucis not defined. 1330fbbaa43SLionel Sambuc.It Fl u 1340fbbaa43SLionel SambucUnique: suppress all but one in each set of lines having equal keys. 1350fbbaa43SLionel SambucIf used with the 1360fbbaa43SLionel Sambuc.Fl c 1370fbbaa43SLionel Sambucoption, check that there are no lines with duplicate keys. 1380fbbaa43SLionel Sambuc.El 1390fbbaa43SLionel Sambuc.Pp 1400fbbaa43SLionel SambucThe following options override the default ordering rules. 1410fbbaa43SLionel SambucWhen ordering options appear independent of key field 1420fbbaa43SLionel Sambucspecifications, the requested field ordering rules are 1430fbbaa43SLionel Sambucapplied globally to all sort keys. 1440fbbaa43SLionel SambucWhen attached to a specific key (see 1450fbbaa43SLionel Sambuc.Fl k ) , 1460fbbaa43SLionel Sambucthe ordering options override 1470fbbaa43SLionel Sambucall global ordering options for that key. 1480fbbaa43SLionel Sambuc.Bl -tag -width Fl 1490fbbaa43SLionel Sambuc.It Fl d 1500fbbaa43SLionel SambucOnly blank space and alphanumeric characters 1510fbbaa43SLionel Sambuc.\" according 1520fbbaa43SLionel Sambuc.\" to the current setting of LC_CTYPE 1530fbbaa43SLionel Sambucare used 1540fbbaa43SLionel Sambucin making comparisons. 1550fbbaa43SLionel Sambuc.It Fl f 1560fbbaa43SLionel SambucConsiders all lowercase characters that have uppercase 1570fbbaa43SLionel Sambucequivalents to be the same for purposes of comparison. 1580fbbaa43SLionel Sambuc.It Fl i 1590fbbaa43SLionel SambucIgnore all non-printable characters. 1600fbbaa43SLionel Sambuc.It Fl l 1610fbbaa43SLionel SambucSort by the string length of the field, not by the field itself. 1620fbbaa43SLionel Sambuc.It Fl n 1630fbbaa43SLionel SambucAn initial numeric string, consisting of optional blank space, optional 164*84d9c625SLionel Sambucplus or minus sign, and zero or more digits (including decimal point) 1650fbbaa43SLionel Sambuc.\" with 1660fbbaa43SLionel Sambuc.\" optional radix character and thousands 1670fbbaa43SLionel Sambuc.\" separator 1680fbbaa43SLionel Sambuc.\" (as defined in the current locale), 1690fbbaa43SLionel Sambucis sorted by arithmetic value. 1700fbbaa43SLionel Sambuc(The 1710fbbaa43SLionel Sambuc.Fl n 1720fbbaa43SLionel Sambucoption no longer implies the 1730fbbaa43SLionel Sambuc.Fl b 1740fbbaa43SLionel Sambucoption.) 1750fbbaa43SLionel Sambuc.It Fl r 1760fbbaa43SLionel SambucReverse the sense of comparisons. 1770fbbaa43SLionel Sambuc.El 1780fbbaa43SLionel Sambuc.Pp 1790fbbaa43SLionel SambucThe treatment of field separators can be altered using these options: 1800fbbaa43SLionel Sambuc.Bl -tag -width Fl 1810fbbaa43SLionel Sambuc.It Fl b 1820fbbaa43SLionel SambucIgnores leading blank space when determining the start 1830fbbaa43SLionel Sambucand end of a restricted sort key. 1840fbbaa43SLionel SambucA 1850fbbaa43SLionel Sambuc.Fl b 1860fbbaa43SLionel Sambucoption specified before the first 1870fbbaa43SLionel Sambuc.Fl k 1880fbbaa43SLionel Sambucoption applies globally to all 1890fbbaa43SLionel Sambuc.Fl k 1900fbbaa43SLionel Sambucoptions. 1910fbbaa43SLionel SambucOtherwise, the 1920fbbaa43SLionel Sambuc.Fl b 1930fbbaa43SLionel Sambucoption can be attached independently to each 1940fbbaa43SLionel Sambuc.Ar field 1950fbbaa43SLionel Sambucargument of the 1960fbbaa43SLionel Sambuc.Fl k 1970fbbaa43SLionel Sambucoption (see below). 1980fbbaa43SLionel SambucNote that the 1990fbbaa43SLionel Sambuc.Fl b 2000fbbaa43SLionel Sambucoption has no effect unless key fields are specified. 2010fbbaa43SLionel Sambuc.It Fl t Ar char 2020fbbaa43SLionel Sambuc.Ar char 2030fbbaa43SLionel Sambucis used as the field separator character. 2040fbbaa43SLionel SambucThe initial 2050fbbaa43SLionel Sambuc.Ar char 2060fbbaa43SLionel Sambucis not considered to be part of a field when determining 2070fbbaa43SLionel Sambuckey offsets (see below). 2080fbbaa43SLionel SambucEach occurrence of 2090fbbaa43SLionel Sambuc.Ar char 2100fbbaa43SLionel Sambucis significant (for example, 2110fbbaa43SLionel Sambuc.Dq Ar charchar 2120fbbaa43SLionel Sambucdelimits an empty field). 2130fbbaa43SLionel SambucIf 2140fbbaa43SLionel Sambuc.Fl t 2150fbbaa43SLionel Sambucis not specified, the default field separator is a sequence of 2160fbbaa43SLionel Sambucblank-space characters, and consecutive blank spaces do 2170fbbaa43SLionel Sambuc.Em not 2180fbbaa43SLionel Sambucdelimit an empty field; further, the initial blank space 2190fbbaa43SLionel Sambuc.Em is 2200fbbaa43SLionel Sambucconsidered part of a field when determining key offsets. 2210fbbaa43SLionel Sambuc.It Fl R Ar char 2220fbbaa43SLionel Sambuc.Ar char 2230fbbaa43SLionel Sambucis used as the record separator character. 2240fbbaa43SLionel SambucThis should be used with discretion; 225*84d9c625SLionel Sambuc.Fl R Aq Ar alphanumeric 2260fbbaa43SLionel Sambucusually produces undesirable results. 2270fbbaa43SLionel SambucThe default record separator is newline. 2280fbbaa43SLionel Sambuc.It Fl k Ar field1 Ns Op Li \&, Ns Ar field2 2290fbbaa43SLionel SambucDesignates the starting position, 2300fbbaa43SLionel Sambuc.Ar field1 , 2310fbbaa43SLionel Sambucand optional ending position, 2320fbbaa43SLionel Sambuc.Ar field2 , 2330fbbaa43SLionel Sambucof a key field. 2340fbbaa43SLionel SambucThe 2350fbbaa43SLionel Sambuc.Fl k 2360fbbaa43SLionel Sambucoption replaces the obsolescent options 2370fbbaa43SLionel Sambuc.Cm \(pl Ns Ar pos1 2380fbbaa43SLionel Sambucand 2390fbbaa43SLionel Sambuc.Fl Ns Ar pos2 . 2400fbbaa43SLionel Sambuc.El 2410fbbaa43SLionel Sambuc.Pp 2420fbbaa43SLionel SambucThe following operands are available: 2430fbbaa43SLionel Sambuc.Bl -tag -width Ar 2440fbbaa43SLionel Sambuc.It Ar file 2450fbbaa43SLionel SambucThe pathname of a file to be sorted, merged, or checked. 2460fbbaa43SLionel SambucIf no 2470fbbaa43SLionel Sambuc.Ar file 2480fbbaa43SLionel Sambucoperands are specified, or if 2490fbbaa43SLionel Sambuca 2500fbbaa43SLionel Sambuc.Ar file 2510fbbaa43SLionel Sambucoperand is 2520fbbaa43SLionel Sambuc.Fl , 2530fbbaa43SLionel Sambucthe standard input is used. 2540fbbaa43SLionel Sambuc.El 2550fbbaa43SLionel Sambuc.Pp 2560fbbaa43SLionel SambucA field is defined as a minimal sequence of characters followed by a 2570fbbaa43SLionel Sambucfield separator or a newline character. 2580fbbaa43SLionel SambucBy default, the first 2590fbbaa43SLionel Sambucblank space of a sequence of blank spaces acts as the field separator. 2600fbbaa43SLionel SambucAll blank spaces in a sequence of blank spaces are considered 2610fbbaa43SLionel Sambucas part of the next field; for example, all blank spaces at 2620fbbaa43SLionel Sambucthe beginning of a line are considered to be part of the 2630fbbaa43SLionel Sambucfirst field. 2640fbbaa43SLionel Sambuc.Pp 2650fbbaa43SLionel SambucFields are specified 2660fbbaa43SLionel Sambucby the 2670fbbaa43SLionel Sambuc.Fl k 2680fbbaa43SLionel Sambuc.Ar field1 Ns Op \&, Ns Ar field2 2690fbbaa43SLionel Sambucargument. 2700fbbaa43SLionel SambucA missing 2710fbbaa43SLionel Sambuc.Ar field2 2720fbbaa43SLionel Sambucargument defaults to the end of a line. 2730fbbaa43SLionel Sambuc.Pp 2740fbbaa43SLionel SambucThe arguments 2750fbbaa43SLionel Sambuc.Ar field1 2760fbbaa43SLionel Sambucand 2770fbbaa43SLionel Sambuc.Ar field2 2780fbbaa43SLionel Sambuchave the form 2790fbbaa43SLionel Sambuc.Ar m Ns Li \&. Ns Ar n 2800fbbaa43SLionel Sambucand can be followed by one or more of the letters 2810fbbaa43SLionel Sambuc.Cm b , d , f , i , 2820fbbaa43SLionel Sambuc.Cm l , n , 2830fbbaa43SLionel Sambucand 2840fbbaa43SLionel Sambuc.Cm r , 2850fbbaa43SLionel Sambucwhich correspond to the options discussed above. 2860fbbaa43SLionel SambucA 2870fbbaa43SLionel Sambuc.Ar field1 2880fbbaa43SLionel Sambucposition specified by 2890fbbaa43SLionel Sambuc.Ar m Ns Li \&. Ns Ar n 2900fbbaa43SLionel Sambuc.Pq Ar m , n No \*[Gt] 0 2910fbbaa43SLionel Sambucis interpreted as the 2920fbbaa43SLionel Sambuc.Ar n Ns th 2930fbbaa43SLionel Sambuccharacter in the 2940fbbaa43SLionel Sambuc.Ar m Ns th 2950fbbaa43SLionel Sambucfield. 2960fbbaa43SLionel SambucA missing 2970fbbaa43SLionel Sambuc.Li \&. Ns Ar n 2980fbbaa43SLionel Sambucin 2990fbbaa43SLionel Sambuc.Ar field1 3000fbbaa43SLionel Sambucmeans 3010fbbaa43SLionel Sambuc.Ql \&.1 , 3020fbbaa43SLionel Sambucindicating the first character of the 3030fbbaa43SLionel Sambuc.Ar m Ns th 3040fbbaa43SLionel Sambucfield; if the 3050fbbaa43SLionel Sambuc.Fl b 3060fbbaa43SLionel Sambucoption is in effect, 3070fbbaa43SLionel Sambuc.Ar n 3080fbbaa43SLionel Sambucis counted from the first non-blank character in the 3090fbbaa43SLionel Sambuc.Ar m Ns th 3100fbbaa43SLionel Sambucfield; 3110fbbaa43SLionel Sambuc.Ar m Ns Li \&.1b 3120fbbaa43SLionel Sambucrefers to the first non-blank character in the 3130fbbaa43SLionel Sambuc.Ar m Ns th 3140fbbaa43SLionel Sambucfield. 3150fbbaa43SLionel Sambuc.Pp 3160fbbaa43SLionel SambucA 3170fbbaa43SLionel Sambuc.Ar field2 3180fbbaa43SLionel Sambucposition specified by 3190fbbaa43SLionel Sambuc.Ar m Ns Li \&. Ns Ar n 3200fbbaa43SLionel Sambucis interpreted as 3210fbbaa43SLionel Sambucthe 3220fbbaa43SLionel Sambuc.Ar n Ns th 3230fbbaa43SLionel Sambuccharacter (including separators) of the 3240fbbaa43SLionel Sambuc.Ar m Ns th 3250fbbaa43SLionel Sambucfield. 3260fbbaa43SLionel SambucA missing 3270fbbaa43SLionel Sambuc.Li \&. Ns Ar n 3280fbbaa43SLionel Sambucindicates the last character of the 3290fbbaa43SLionel Sambuc.Ar m Ns th 3300fbbaa43SLionel Sambucfield; 3310fbbaa43SLionel Sambuc.Ar m 3320fbbaa43SLionel Sambuc= \&0 3330fbbaa43SLionel Sambucdesignates the end of a line. 3340fbbaa43SLionel SambucThus the option 3350fbbaa43SLionel Sambuc.Fl k 3360fbbaa43SLionel Sambuc.Sm off 3370fbbaa43SLionel Sambuc.Xo 3380fbbaa43SLionel Sambuc.Ar v Li \&. Ar x Li \&, 3390fbbaa43SLionel Sambuc.Ar w Li \&. Ar y 3400fbbaa43SLionel Sambuc.Xc 3410fbbaa43SLionel Sambuc.Sm on 3420fbbaa43SLionel Sambucis synonymous with the obsolescent option 3430fbbaa43SLionel Sambuc.Sm off 3440fbbaa43SLionel Sambuc.Cm \(pl Ar v-\&1 Li \&. Ar x-\&1 3450fbbaa43SLionel Sambuc.Fl Ar w-\&1 Li \&. Ar y ; 3460fbbaa43SLionel Sambuc.Sm on 3470fbbaa43SLionel Sambucwhen 3480fbbaa43SLionel Sambuc.Ar y 3490fbbaa43SLionel Sambucis omitted, 3500fbbaa43SLionel Sambuc.Fl k 3510fbbaa43SLionel Sambuc.Sm off 3520fbbaa43SLionel Sambuc.Ar v Li \&. Ar x Li \&, Ar w 3530fbbaa43SLionel Sambuc.Sm on 3540fbbaa43SLionel Sambucis synonymous with 3550fbbaa43SLionel Sambuc.Sm off 3560fbbaa43SLionel Sambuc.Cm \(pl Ar v-\&1 Li \&. Ar x-\&1 3570fbbaa43SLionel Sambuc.Fl Ar w+1 Li \&.0 . 3580fbbaa43SLionel Sambuc.Sm on 3590fbbaa43SLionel SambucThe obsolescent 3600fbbaa43SLionel Sambuc.Cm \(pl Ns Ar pos1 3610fbbaa43SLionel Sambuc.Fl Ns Ar pos2 3620fbbaa43SLionel Sambucoption is still supported, except for 3630fbbaa43SLionel Sambuc.Fl Ns Ar w Ns Li \&.0b , 3640fbbaa43SLionel Sambucwhich has no 3650fbbaa43SLionel Sambuc.Fl k 3660fbbaa43SLionel Sambucequivalent. 3670fbbaa43SLionel Sambuc.Sh ENVIRONMENT 3680fbbaa43SLionel SambucIf the following environment variable exists, it is used by 3690fbbaa43SLionel Sambuc.Nm . 3700fbbaa43SLionel Sambuc.Bl -tag -width Ev 3710fbbaa43SLionel Sambuc.It Ev TMPDIR 3720fbbaa43SLionel Sambuc.Nm 3730fbbaa43SLionel Sambucuses the contents of the 3740fbbaa43SLionel Sambuc.Ev TMPDIR 3750fbbaa43SLionel Sambucenvironment variable as the path in which to store 3760fbbaa43SLionel Sambuctemporary files. 3770fbbaa43SLionel Sambuc.El 3780fbbaa43SLionel Sambuc.Sh FILES 3790fbbaa43SLionel Sambuc.Bl -tag -width outputNUMBER+some -compact 3800fbbaa43SLionel Sambuc.It Pa /tmp/sort.* 3810fbbaa43SLionel SambucDefault temporary files. 3820fbbaa43SLionel Sambuc.It Ar output Ns NUMBER 3830fbbaa43SLionel SambucTemporary file which is used for output if 3840fbbaa43SLionel Sambuc.Ar output 3850fbbaa43SLionel Sambucalready exists. 3860fbbaa43SLionel SambucOnce sorting is finished, this file replaces 3870fbbaa43SLionel Sambuc.Ar output 3880fbbaa43SLionel Sambuc(via 3890fbbaa43SLionel Sambuc.Xr link 2 3900fbbaa43SLionel Sambucand 3910fbbaa43SLionel Sambuc.Xr unlink 2 ) . 3920fbbaa43SLionel Sambuc.El 3930fbbaa43SLionel Sambuc.Sh EXIT STATUS 3940fbbaa43SLionel SambucSort exits with one of the following values: 3950fbbaa43SLionel Sambuc.Bl -tag -width flag -compact 3960fbbaa43SLionel Sambuc.It 0 3970fbbaa43SLionel SambucNormal behavior. 3980fbbaa43SLionel Sambuc.It 1 3990fbbaa43SLionel SambucOn disorder (or non-uniqueness) with the 4000fbbaa43SLionel Sambuc.Fl c 4010fbbaa43SLionel Sambucoption 4020fbbaa43SLionel Sambuc.It 2 4030fbbaa43SLionel SambucAn error occurred. 4040fbbaa43SLionel Sambuc.El 4050fbbaa43SLionel Sambuc.Sh SEE ALSO 4060fbbaa43SLionel Sambuc.Xr comm 1 , 4070fbbaa43SLionel Sambuc.Xr join 1 , 4080fbbaa43SLionel Sambuc.Xr uniq 1 , 4090fbbaa43SLionel Sambuc.Xr qsort 3 , 4100fbbaa43SLionel Sambuc.Xr radixsort 3 4110fbbaa43SLionel Sambuc.Sh HISTORY 4120fbbaa43SLionel SambucA 4130fbbaa43SLionel Sambuc.Nm 4140fbbaa43SLionel Sambuccommand appeared in 4150fbbaa43SLionel Sambuc.At v5 . 4160fbbaa43SLionel SambucThis 4170fbbaa43SLionel Sambuc.Nm 4180fbbaa43SLionel Sambucimplementation appeared in 4190fbbaa43SLionel Sambuc.Bx 4.4 4200fbbaa43SLionel Sambucand is used since 4210fbbaa43SLionel Sambuc.Nx 1.6 . 4220fbbaa43SLionel Sambuc.Sh BUGS 4230fbbaa43SLionel SambucPosix requires the locale's thousands separator be ignored in numbers. 4240fbbaa43SLionel SambucIt may be faster to sort very large files in pieces and then explicitly 4250fbbaa43SLionel Sambucmerge them. 4260fbbaa43SLionel Sambuc.Sh NOTES 4270fbbaa43SLionel SambucThis 4280fbbaa43SLionel Sambuc.Nm 4290fbbaa43SLionel Sambuchas no limits on input line length (other than imposed by available 4300fbbaa43SLionel Sambucmemory) or any restrictions on bytes allowed within lines. 4310fbbaa43SLionel Sambuc.Pp 4320fbbaa43SLionel SambucTo protect data 4330fbbaa43SLionel Sambuc.Nm 4340fbbaa43SLionel Sambuc.Fl o 4350fbbaa43SLionel Sambuccalls 4360fbbaa43SLionel Sambuc.Xr link 2 4370fbbaa43SLionel Sambucand 4380fbbaa43SLionel Sambuc.Xr unlink 2 , 4390fbbaa43SLionel Sambucand thus fails on protected directories. 4400fbbaa43SLionel Sambuc.Pp 4410fbbaa43SLionel SambucInput files should be text files. 4420fbbaa43SLionel SambucIf file doesn't end with record separator (which is typically newline), the 4430fbbaa43SLionel Sambuc.Nm 4440fbbaa43SLionel Sambucutility silently supplies one. 4450fbbaa43SLionel Sambuc.Pp 4460fbbaa43SLionel SambucThe current 4470fbbaa43SLionel Sambuc.Nm 4480fbbaa43SLionel Sambucuses lexicographic radix sorting, which requires 4490fbbaa43SLionel Sambucthat sort keys be kept in memory (as opposed to previous versions which used quick 4500fbbaa43SLionel Sambucand merge sorts and did not.) 4510fbbaa43SLionel SambucThus performance depends highly on efficient choice of sort keys, and the 4520fbbaa43SLionel Sambuc.Fl b 4530fbbaa43SLionel Sambucoption and the 4540fbbaa43SLionel Sambuc.Ar field2 4550fbbaa43SLionel Sambucargument of the 4560fbbaa43SLionel Sambuc.Fl k 4570fbbaa43SLionel Sambucoption should be used whenever possible. 4580fbbaa43SLionel SambucSimilarly, 4590fbbaa43SLionel Sambuc.Nm 4600fbbaa43SLionel Sambuc.Fl k1f 4610fbbaa43SLionel Sambucis equivalent to 4620fbbaa43SLionel Sambuc.Nm 4630fbbaa43SLionel Sambuc.Fl f 4640fbbaa43SLionel Sambucand may take twice as long. 465