?? sort.1
字號:
.\" $OpenBSD: sort.1,v 1.21 2003/07/14 12:56:07 jmc Exp $.\".\" 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..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. Neither the name of the University nor the names of its contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" @(#)sort.1 8.1 (Berkeley) 6/6/93.\".Dd June 6, 1993.Dt SORT 1.Os.Sh NAME.Nm sort.Nd sort or merge text files.Sh SYNOPSIS.Nm sort.Op Fl cmubdfinrH.Op Fl t Ar char.Op Fl R Ar char.Oo.Fl k Ar field1[,field2].Oc.Ar ....Op Fl T Ar dir.Op Fl o Ar output.Op Ar file.Ar ....Sh DESCRIPTIONThe.Nmutility sorts text files by lines.Comparisons are based on one or more sort keys extractedfrom each line of input, and are performed lexicographically.By default, if keys are not given,.Nmregards each input line as a single field..PpThe options are as follows:.Bl -tag -width Ds.It Fl cCheck that the single input file is sorted.If the file is not sorted,.Nmproduces the appropriate error messages and exits with code 1; otherwise,.Nmreturns 0..Nm.Fl cproduces no output, except the error messages on.Em stderr ..It Fl mMerge only; the input files are assumed to be pre-sorted..It Fl o Ar outputThe argument given is the name of an.Ar outputfile to be used instead of the standard output.This file can be the same as one of the input files..It Fl T Ar dirUse.Ar diras the directory for temporary files.The default is the contents of the environment variable.Ev TMPDIRor.Pa /var/tmpif.Ev TMPDIRdoes not exist..It Fl uUnique: suppress all but one in each set of lines having equal keys.If used with the.Fl coption, check that there are no lines with duplicate keys..El.PpThe following options override the default ordering rules.When ordering options appear independent of key fieldspecifications, the requested field ordering rules areapplied globally to all sort keys.When attached to a specific key (see.Fl k ) ,the ordering options overrideall global ordering options for that key..Bl -tag -width indent.It Fl dOnly blank space and alphanumeric characters.\" according.\" to the current setting of LC_CTYPEare used in making comparisons..It Fl fConsiders all lowercase characters that have uppercaseequivalents to be the same for purposes of comparison..It Fl iIgnore all non-printable characters..It Fl nAn initial numeric string, consisting of optional blank space, optionalminus sign, and zero or more digits (including decimal point).\" with.\" optional radix character and thousands.\" separator.\" (as defined in the current locale),is sorted by arithmetic value.(The.Fl noption no longer implies the.Fl boption.).It Fl rReverse the sense of comparisons..It Fl HUse a merge sort instead of a radix sort.This option should be used for files larger than 60Mb..El.PpThe treatment of field separators can be altered using these options:.Bl -tag -width indent.It Fl bIgnores leading blank space when determining the startand end of a restricted sort key.A.Fl boption specified before the first.Fl koption applies globally to all.Fl koptions.Otherwise, the.Fl boption can be attached independently to each.Ar fieldargument of the.Fl koption (see below).Note that the.Fl boption has no effect unless key fields are specified..It Fl t Ar char.Ar charis used as the field separator character.The initial.Ar charis not considered to be part of a field when determining key offsets.Each occurrence of.Ar charis significant (for example,.Dq Ar charchardelimits an empty field).If.Fl tis not specified, the default field separator is a sequence ofblank-space characters, and consecutive blank spaces do.Em notdelimit an empty field; further, the initial blank space.Em isconsidered part of a field when determining key offsets..It Fl R Ar char.Ar charis used as the record separator character.This should be used with discretion;.Fl R Ar <alphanumeric>usually produces undesirable results.The default record separator is newline..It Fl k Ar field1[,field2]Designates the starting position,.Ar field1 ,and optional ending position,.Ar field2 ,of a key field.The.Fl koption replaces the obsolescent options.Cm \(pl Ns Ar pos1and.Fl Ns Ar pos2 ..El.PpThe following operands are available:.Bl -tag -width indent.It Ar fileThe pathname of a file to be sorted, merged, or checked.If no.Ar fileoperands are specified, or if a.Ar fileoperand is.Fl ,the standard input is used..El.PpA field is defined as a maximal sequence of characters other than thefield separator and record separator.Pq newline by default .Initial blank spaces are included in the field unless.Fl bhas been specified;the first blank space of a sequence of blank spaces acts as the fieldseparator and is included in the field (unless.Fl tis specified).For example, by default all blank spaces at the beginning of a line areconsidered to be part of the first field..PpFields are specified by the.Fl k Ar field1[,field2]argument.A missing.Ar field2argument defaults to the end of a line..PpThe arguments.Ar field1and.Ar field2have the form.Em m.n.Em (m,n > 0)and can be followed by one or more of the letters.Cm b , d , f , i ,.Cm n ,and.Cm r ,which correspond to the options discussed above.A.Ar field1position specified by.Em m.nis interpreted as the.Em n Ns thcharacter from the beginning of the.Em m Ns thfield.A missing.Em \&.nin.Ar field1means.Ql \&.1 ,indicating the first character of the.Em m Ns thfield; if the.Fl boption is in effect,.Em nis counted from the first non-blank character in the.Em m Ns thfield;.Em m Ns \&.1brefers to the first non-blank character in the.Em m Ns thfield..No 1\&. Ns Em nrefers to the.Em n Ns thcharacter from the beginning of the line;if.Em nis greater than the length of the line, the field is taken to be empty..PpA.Ar field2position specified by.Em m.nis interpreted as the.Em n Ns thcharacter (including separators) of the.Em m Ns thfield.A missing.Em \&.nindicates the last character of the.Em m Ns thfield;.Em m= \&0designates the end of a line.Thus the option.Fl k Ar v.x,w.yis synonymous with the obsolescent option.Cm \(pl Ns Ar v-\&1.x-\&1.Fl Ns Ar w-\&1.y ;when.Em yis omitted,.Fl k Ar v.x,wis synonymous with.Cm \(pl Ns Ar v-\&1.x-\&1.Fl Ns Ar w\&.0 .The obsolescent.Cm \(pl Ns Ar pos1.Fl Ns Ar pos2option is still supported, except for.Fl Ns Ar w\&.0b ,which has no.Fl kequivalent..PpThe.Nmutility shall exit with one of the following values:.Pp.Bl -tag -width flag -compact.It 0Normal behavior..It 1On disorder (or non-uniqueness) with the.Fl coption..It 2An error occurred..El.Sh ENVIRONMENT.Bl -tag -width Fl.It Ev TMPDIRPath in which to store temporary files.Note that.Ev TMPDIRmay be overridden by the.Fl Toption..El.Sh FILES.Bl -tag -width Pa -compact.It Pa /var/tmp/sort.*default temporary directories.It Pa Ar output Ns #PIDtemporary name for.Ar outputif.Ar outputalready exists.El.Sh SEE ALSO.Xr comm 1 ,.Xr join 1 ,.Xr uniq 1 ,.Xr radixsort 3.Sh HISTORYA.Nmcommand appeared in.At v3 ..Sh NOTES.Nmhas no limits on input line length (other than imposed by availablememory) or any restrictions on bytes allowed within lines..PpTo protect data.Nm.Fl ocalls.Xr link 2and.Xr unlink 2 ,and thus fails on protected directories..PpThe current sort command uses lexicographic radix sorting, which requiresthat sort keys be kept in memory (as opposed to previous versions whichused quick and merge sorts and did not).Thus performance depends highly on efficient choice of sort keys, and the.Fl boption and the.Ar field2argument of the.Fl koption should be used whenever possible.Similarly,.Nm.Fl k1fis equivalent to.Nm.Fl fand may take twice as long..Sh BUGSTo sort files larger than 60Mb, use.Nm.Fl H ;files larger than 704Mb must be sorted in smaller pieces, then merged.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -