Forrest logo
back to the tree tool

tree:tldr:b776d

tree: Print files within the tree hierarchy, using a wildcard (glob) pattern, and pruning out directories that don't contain matching files.
$ tree -P '${*-txt}' --prune
try on your machine

The command "tree" is a command-line utility that displays the directory structure of a given file system in a tree-like format.

In this command, the option "-P '${*-txt}'" is used to filter and display only the files that match the specified pattern.

The pattern '${-txt}' is a wildcard expression that matches all files ending with ".txt". Here, '${}' represents any characters (wildcard) before the extension "-txt". Therefore, this pattern will match any file with any name before the ".txt" extension.

The "--prune" option is used to exclude empty directories from the tree view. If a directory does not contain any files or subdirectories, it will be skipped and not displayed in the tree structure.

To summarize, the command "tree -P '${*-txt}' --prune" will generate a tree view of the file system, displaying only the files ending with ".txt" and excluding any empty directories.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the tree tool