Sort



next up previous contents index
Next: Word Count: wc Up: Unix Toolkit Previous: Smart File Splitters:

Sort

Sort will order a file or standard input. You can choose which field to sort and can sort either alphabetically or numerically. 


SORT OPTIONS
+i
Skip i fields, sort on the i+1 field.
-i
Stop sorting after the i field.
-t'c'
Use c as the character which separates fields.
-b
Ignore blanks.
-n
Sort by numerical value.
-r
Reverse the order of the sort.
-u
Remove any duplicate lines.
-f
Merge upper and lowercase.
-d
Dictionary order.

You can sort by number or name. To find the largest files, sort the output of ls -s:

% sort +3 -t':' -n /etc/passwd   	Numerical sort on 4th field.   
% sort /etc/passwd   	Alphabetical sort.   
% ls -s | sort -n   	Numerical sort for large files.   



next up previous contents index
Next: Word Count: wc Up: Unix Toolkit Previous: Smart File Splitters: