Linux Command Directory
This directory of Linux commands is from Linux in a Nutshell, 5th Edition.
Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.
sort [options] [files]
Sort the lines of the named files. Compare specified fields for each pair of lines; if no fields are specified, compare them by byte, in machine-collating sequence. If no files are specified or if the file is -, the input is taken from standard input. See also uniq, comm, and join.
Ignore leading spaces and tabs.
Check whether files are already sorted and, if so, produce no output.
Sort in dictionary order.
Fold; ignore uppercase/lowercase differences.
Sort in general numeric order.
Print a help message and then exit.
Ignore nonprinting characters (those outside ASCII range 040-176).
Skip n-1 fields and stop at m-1 fields (i.e., start sorting at the nth field, where the fields are numbered beginning with 1).
Sort in arithmetic order.
Put output in file.
Merge already sorted input files.
Reverse the order of the sort.
Stabilize sort by disabling last-resort comparison.
Separate fields with c (default is a tab).
Identical lines in input file appear only one time in output.
End lines with zero byte, not with newline.
Print version information and then exit.
Attempt to treat the first three characters as a month designation (JAN, FEB, etc.). In comparisons, treat JAN < FEB and any invalid name for a month as less than a valid month.
Set the size of the main memory buffer to size, which may include a suffix—e.g., K (1024, the default) or M.
Directory pathname to be used for temporary files.
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 -nk3,4 -t: /etc/passwd