sort

Official Description

Sorts or merges files.

Syntax

sort [-m] [-o output_file] [-Abdfinru] [-k keydef]... [-t character]
          [-T directory] [-y] [kilobytes] [-z record_size]... file...
				

Options

-m performs a merge.

-b ignores leading spaces and tabs.

-f treats lowercase as uppercase.

-k keydef specifies one or more sort keys (start byte, end byte).

-n sorts any initial numeric strings.

-r reverses the order.

-u means no duplicates in output.

Oddities

No separate merge command exists.

Example

 $ sort buzz # Standard sort #! /bin/ksh do done integer x=17 while : x=17 $ sort -r buzz # Descending sort x=17 while : integer x=17 done do #! /bin/ksh $ $ sort -k 3,1 buzz # Use one byte found after skipping three as # the sort key #! /bin/ksh do done ...

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.