home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: soelim Chapter 2
UNIX Commands
Next: Reference: spell





] [



Sort the lines of the named files , typically in alphabetical order. See also uniq , comm , join .



Ignore leading spaces and tabs.


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


Sort in dictionary order (ignore punctuation).


"Fold"; ignore uppercase/lowercase differences.


Ignore nonprinting characters (those outside ASCII range 040-176).


Merge sorted input files.


Compare first three characters as months.


Sort in arithmetic order.

-o file

Put output in file .


Reverse the order of the sort.

-t c

Fields are separated with c (default is any white space).


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

-y kmem

Adjust the amount of memory (in kilobytes) sort uses. If kmem is not specified, allocate the maximum memory.

-z recsz

Provide the maximum number of 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.


List files by decreasing number of lines:

wc -l * | sort -r

Alphabetize a list of words, remove duplicates, and print the frequency of each word:

sort -fd wordlist | uniq -c

Sort the password file numerically by the third field (user ID):

sort +2n -t: /etc/passwd

Previous: Reference: soelim UNIX in a Nutshell: System V Edition Next: Reference: spell
Reference: soelim Book Index Reference: spell

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System