A file tree utility
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



License standard-readme compliant

A file tree utility


Table of Contents


Forest is a small program used for viewing and searching the file tree. It is heavily inspired by the tree command and one of my assignments for CSC209 at UofT.


$ git clone https://github.com/patrickleweryharris/forest.git

$ cd forest

$ make



To print the file tree for a specific directory use:

$./print_forest DIRECTORY

Where DIRECTORY is the relative path


Running search_forest will search the file tree for items that match your search criteria. Searches can be done by name, permissions, type or regex. Regex searches are a more sophisticated version of the name search.


Where MODE is the search mode you want to use, DIRECTORY is the relative path. SIZE_COMP denotes the size used to compare in SIZE mode.

Only one of FILENAME, PERMS, FILETYPE or OPERATION may be included, corresponding to the search mode.

Include SIZE_COMP only if searching by size.

Input FILENAME if searching by name or regex, PERMS if searching by perms, FILETYPE if searching by type or OPERATION if searching by size.

Search modes:

#define NAME 0
#define PERM 1
#define TYPE 2
#define REGEX 3
#define SIZE 4

Type Codes:

#define REGFILE 0 // 'FILE'
#define REGDIR 1 // 'DIR'

Size comparison operations

#define EQUALS 0 // '='
#define LEQ 1 // '<='
#define GEQ 2 // '>='
#define GREATER 3 // '>'
#define LESS 4 // '<'
#define NEQ 5 // '!='


$ ./search_forest . NAME forest.c

This search searches for files with the file name "forest.c" in the current directory

$ ./search_forest . PERM 420

This search searches for files with permissions code 420 in the current directory

$ ./search_forest . TYPE DIR

This search searches for directories in the current directory

$ ./search_forest . REGEX forest

This searches using regex 'forest', returning all items that contain 'forest' in the current directory

$ ./search_forest . SIZE '>' 408

This searches by size, returning all items with size greater than 408 bytes. The greater than symbol needs to be in quotes as > and < are reserved in bash for stdin and stdout redirection operations


Path length of a file object is limited to 128 characters, so the forest structure works better on small directories.

This path length can be changed by altering the constant MAXPATH in forest.h though.

The print_forest function similarly works best on small directories.


PRs accepted.

Small note: If editing the Readme, please conform to the standard-readme specification.


MIT © Patrick Harris