← 返回命令列表

Linux command

tsort 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Sort dependencies

tsort [dependencies.txt]

From stdin

echo -e "a b\nb c" | tsort

Sort makefile dependencies

tsort [makefile_deps]

说明

tsort performs topological sorting on a set of dependency pairs read from standard input or a file. Each line contains two whitespace-separated items where the first item depends on the second. The output lists all items in an order where every dependency appears before the items that depend on it. The tool is commonly used in build systems to determine compilation order, in package managers to resolve installation sequences, and in any scenario where items must be processed in dependency order. If the input contains cycles (circular dependencies), tsort reports an error since no valid ordering exists. Input with a single item on a line introduces that item without declaring a dependency, ensuring it appears in the output.

参数

--help
Display help information.
--version
Output version information and exit.

FAQ

What is the tsort command used for?

tsort performs topological sorting on a set of dependency pairs read from standard input or a file. Each line contains two whitespace-separated items where the first item depends on the second. The output lists all items in an order where every dependency appears before the items that depend on it. The tool is commonly used in build systems to determine compilation order, in package managers to resolve installation sequences, and in any scenario where items must be processed in dependency order. If the input contains cycles (circular dependencies), tsort reports an error since no valid ordering exists. Input with a single item on a line introduces that item without declaring a dependency, ensuring it appears in the output.

How do I run a basic tsort example?

Run `tsort [dependencies.txt]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --help do in tsort?

Display help information.