SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

BotDetect - Real-Time Bot Detection API
 
 

MAN page from Old RedHat 5.X textutils-1.22-5.i386.rpm

SORT

Section: User Commands (1)
Updated: GNU Text Utilities
Index 

NAME

sort - sort lines of text files 

SYNOPSIS

sort[-cmus] [-t separator] [-o output-file] [-T tempdir] [-bdfiMnr][+POS1 [-POS2]] [-k POS1[,POS2]] [file...]
sort{--help,--version} 

DESCRIPTION

This documentation is no longer being maintained and may be inaccurateor incomplete. The Texinfo documentation is now the authoritative source.

This manual pagedocuments the GNU version ofsort.sortsorts, merges, or compares all the lines from the given files, or the standardinput if no files are given. A file name of `-' means standard input.By default,sortwrites the results to the standard output.

sorthas three modes of operation: sort (the default), merge, and check forsortedness. The following options change the operation mode:

-c
Check whether the given files are already sorted: if they are not allsorted, print an error message and exit with a status of 1.
-m
Merge the given files by sorting them as a group. Each input fileshould already be individually sorted. It always works to sortinstead of merge; merging is provided because it is faster, in thecase where it works.

A pair of lines is compared as follows: if any key fields have been specified,sortcompares each pair of fields, in the order specified on the commandline, according to the associated ordering options, until a differenceis found or no fields are left.

If any of the global optionsMbdfinrare given but no key fields are specified,sortcompares the entire lines according to the global options.

Finally, as a last resort when all keys compare equal(or if no ordering options were specified at all),sortcompares the lines byte by byte in machine collating sequence.The last resort comparison honors the-rglobal option.The-s(stable) option disables this last-resort comparison so thatlines in which all fields compare equal are left in their originalrelative order. If no fields or global options are specified,-shas no effect.

GNUsorthas no limits on input line length or restrictions on bytes allowedwithin lines. In addition, if the final byte of an input file is nota newline, GNUsortsilently supplies one.

If the environment variableTMPDIRis set,sortuses it as the directory in which to put temporary files instead ofthe default, /tmp. The-T tempdiroption is another way to select the directory for temporary files; itoverrides the environment variable.

The following options affect the ordering of output lines. They maybe specified globally or as part of a specific key field. If no keyfields are specified, global options apply to comparison of entirelines; otherwise the global options are inherited by key fields thatdo not specify any special options of their own.

-b
Ignore leading blanks when finding sort keys in each line.
-d
Sort in `phone directory' order: ignore all characters except letters,digits and blanks when sorting.
-f
Fold lower case characters into the equivalent upper case characterswhen sorting so that, for example, `b' is sorted the same way `B' is.
-i
Ignore characters outside the ASCII range 040-0176 octal (inclusive)when sorting.
-M
An initial string, consisting of any amount of white space, followed by three letters abbreviating a month name, is folded to UPPER case and compared in the order `JAN' < `FEB' < ... < `DEC.' Invalid names compare low to valid names.
-n
Compare according to arithmetic value an initial numeric stringconsisting of optional white space, an optional - sign, and zero ormore digits, optionally followed by a decimal point and zero or moredigits.
-r
Reverse the result of comparison, so that lines with greater keyvalues appear earlier in the output instead of later.

Other options are:

-o output-file
Write output tooutput-fileinstead of to the standard output. Ifoutput-fileis one of the input files,sortcopies it to a temporary file before sorting and writing the output tooutput-file.
-t separator
Use characterseparatoras the field separator when finding the sort keys in each line. Bydefault, fields are separated by the empty string between anon-whitespace character and a whitespace character. That is to say,given the input line ` foo bar',sortbreaks it into fields ` foo' and ` bar'. The field separator is notconsidered to be part of either the field preceding or the fieldfollowing it.
-u
For the default case or the-moption, only output the first of a sequence of lines that compareequal. For the-coption, check that no pair of consecutive lines compares equal.
+POS1 [-POS2]
Specify a field within each line to use as a sorting key. The fieldconsists of the portion of the line starting at POS1 and up to (butnot including) POS2 (or to the end of the line if POS2 is not given).The fields and character positions are numbered starting with 0.
-k POS1[,POS2]
An alternate syntax for specifying sorting keys.The fields and character positions are numbered starting with 1.

A position has the form f.c, where f is the numberof the field to use and c is the number of the first characterfrom the beginning of the field (for +pos) or from the end ofthe previous field (for -pos). The .c part of a positionmay be omitted in which case it is taken to be the first character inthe field. If the-boption has been given, the .c part of a field specification iscounted from the first nonblank character of the field (for+pos) or from the first nonblank character following theprevious field (for -pos).

A +pos or -pos argument may also have any of the optionlettersMbdfinrappended to it, in which case the global ordering options are not usedfor that particular field. The-boption may be independently attached to either or both of the+pos and -pos parts of a field specification, and if itis inherited from the global options it will be attached to both.If a-nor-Moption is used, thus implying a-boption, the-boption is taken to apply to both the +pos and the -posparts of a key specification. Keys may span multiple fields.

In addition, when GNUsortis invoked with exactly one argument, the following options are recognized:

--help
Print a usage message on standard output and exit successfully.
--version
Print version information on standard output then exit successfully.
 

COMPATIBILITY

Historical (BSD and System V) implementations ofsorthave differed in their interpretation of some options,particularly-b,-f,and-n.GNU sort follows the POSIX behavior, which isusually (but not always!) like the System V behavior.According to POSIX-nno longer implies-b.For consistency,-Mhas been changed in the same way.This may affect the meaning of character positions in fieldspecifications in obscure cases.If this bites you the fix is to add an explicit-b. 

BUGS

The different meaning of field numbers dependingon whether-kis used is confusing.It's all POSIX's fault!


 

Index

NAME
SYNOPSIS
DESCRIPTION
COMPATIBILITY
BUGS

This document was created byman2html,using the manual pages.
 
ICM Bot detect detector