Usage - Description - Example
- Options - Limitations
- Return codes
tsort [log logfile] [options] [from infile] [to outfile] expr [...]
tsort sorts infile on the results of the given expression(s), and writes the sorted data to outfile. Expressions are as for tcols.
infile must be an ASCII text file. tsort sees each input line as a row of (by default) whitespace-separated fields; see tcols for more info.
tsort ignores empty (whitespace only) input lines.
tsort compares data the same way as trows does.
tsort retains the relative order of lines for which the expressions evaluate the same.
The output lines are identical to the input lines. tsort only changes their order.
If you don't specify infile, tsort reads from standard input.
If you don't specify outfile, tsort writes to standard output.
If you don't specify logfile, tsort writes error messages to standard
error.
Consider the file "records.txt":
Band "The Band" 1969 "Violent Femmes" "Violent Femmes" 1983 Beatles Revolver 1966 Beatles "Rubber Soul" 1965 "Waits, Tom" Swordfishtrombones 1983 Band "Music From Big Pink" 1968
The command:
tsort from records.txt $1.duqt $3
sorts the records on band/artist name (stripped of surrounding double quotes) and further on year of release, printing:
Band "Music From Big Pink" 1968 Band "The Band" 1969 Beatles "Rubber Soul" 1965 Beatles Revolver 1966 "Violent Femmes" "Violent Femmes" 1983 "Waits, Tom" Swordfishtrombones 1983
tsort recognizes the following command line options:
Option | Function |
---|---|
-iC | Separate input fields by character C (except \). Use \t to form a tab. |
-d | Sort on descending values. |
-he | Print summary of expression usage to standard output, then exit. |
-hf | Print summary of all functions to standard output, then exit. |
-hf name | Print summary of named function to standard output, then exit. |
-v | Print banner with version number to standard error (or logfile, if used), then exit. |
tsort has the same limitations as tcols.
tsort runs out of memory when infile, or the expressions evaluated thereof, are too large.
tsort returns with one of the following codes ("error levels"):
Code | Meaning |
---|---|
0 | Success |
101 | Out of memory |
102 | Incorrect command line arguments |
104 | Error opening file |
105 | I/O error |
106 | Capacity overrun |
107 | File name clash |
109 | Bad input data |