O'Reilly logo

Mac OS X Tiger in a Nutshell by Jason McIntosh, Chuck Toporek, Chris Stone, Andy Lester

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

sort

Synopsis

sort [options] [files]

Sorts the lines of the named files. Compare specified fields for each pair of lines, or, if no fields are specified, compare them by byte, in machine collating sequence. See also uniq , comm , and join .

Options

-b

Ignore leading spaces and tabs.

-c

Check whether files are already sorted, and if so, produce no output.

-d

Sort in "phone directory" order, ignoring all characters except letters, digits, and blanks.

-f

Fold; ignore uppercase/lowercase differences.

-i

Ignore nonprinting characters (those outside ASCII 32 (space) to 126 (tilde)).

-m

Merge (i.e., sort as a group) input files.

-M

Attempt to treat the first three characters as a month designation (JAN, FEB, etc.). In comparisons, treat JAN < FEB and any valid month as less than an invalid name for a month.

-n

Sort in arithmetic order.

-o file

Put output in file.

-r

Reverse the order of the sort.

-t c

Separate fields with c (default is a tab).

-u

Identical lines in input file appear only one (unique) time in output.

-z recsz

Provide recsz bytes for any one line in the file. This option prevents abnormal termination of sort in certain cases.

+ n [- m]

Skip n fields before sorting, and sort up to field position m. If m is missing, sort to end of line. Positions take the form a.b, which means character b of field a. If .b is missing, sort at the first character of the field.

-k n[,m]

Similar to +. Skip n-1 fields and stop at m-1 fields (i.e., start sorting at the nth field, where the fields ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required