tsort - topological sort
tsort [file]
The tsort utility writes to standard output a totally ordered list of items consistent with a partial ordering of items contained in the input.The input consists of pairs of items (non-empty strings) separated by blanks. Pairs of different items indicate ordering. Pairs of identical items indicate presence, but not ordering.
None.
The following operand is supported:
- file
- A pathname of a text file to order. If no file operand is given, the standard input is used.
The standard input is a text file that is used if no file operand is given.
The input file named by the file operand is a text file.
The following environment variables affect the execution of tsort:
- LANG
- Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
- LC_ALL
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- LC_CTYPE
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files).
- LC_MESSAGES
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- NLSPATH
- Determine the location of message catalogues for the processing of LC_MESSAGES .
Default.
The standard output is a text file consisting of the order list produced from the partially ordered input.
Used only for diagnostic messages.
None.
None.
The following exit values are returned:
- 0
- Successful completion.
- >0
- An error occurred.
Default.
The LC_COLLATE variable need not affect the actions of tsort. The output ordering is not lexicographic, but depends on the pairs of items given as input.
The command:tsort <<EOF a b c c d e g g f g e f h h EOF
produces the output:
a b c d e f g h
None.
None.