{"id":1090,"date":"2022-02-20T21:43:03","date_gmt":"2022-02-20T16:13:03","guid":{"rendered":"https:\/\/mutesoft.com\/spaces\/software\/?p=1090"},"modified":"2023-01-13T14:41:15","modified_gmt":"2023-01-13T09:11:15","slug":"tree-command-for-mac-linux-and-windows","status":"publish","type":"post","link":"https:\/\/mutesoft.com\/spaces\/software\/tree-command-for-mac-linux-and-windows.html","title":{"rendered":"View Files in Tree Structure for Mac, Linux and Windows"},"content":{"rendered":"\n<p>Tree command recursively lists files and folders in a tree structure. This provides an excellent overview of what a folder contains. On Windows <code>tree<\/code> command is available by default. However, there is no default <code>tree<\/code> command available on Linux and Mac. In this article, I&#8217;ll share steps to use <code>tree<\/code> command on Mac, Linux, and Windows.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mutesoft.com\/spaces\/software\/tree-command-for-mac-linux-and-windows.html\/#Tree_Command_for_Mac\" >Tree Command for Mac<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mutesoft.com\/spaces\/software\/tree-command-for-mac-linux-and-windows.html\/#Option_1_Install_tree_Tool_using_brew\" >Option 1: Install tree Tool using brew<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mutesoft.com\/spaces\/software\/tree-command-for-mac-linux-and-windows.html\/#Option_2_Use_find_Command_with_an_Alias\" >Option 2: Use find Command with an Alias<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mutesoft.com\/spaces\/software\/tree-command-for-mac-linux-and-windows.html\/#Tree_Command_for_Linux\" >Tree Command for Linux<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mutesoft.com\/spaces\/software\/tree-command-for-mac-linux-and-windows.html\/#Tree_Command_for_Windows\" >Tree Command for Windows<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"tree-command-for-mac\"><span class=\"ez-toc-section\" id=\"Tree_Command_for_Mac\"><\/span>Tree Command for Mac<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>On Mac, the <code>tree<\/code> command is not available by default. There are two options:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install <code>tree<\/code> tool using <code>brew<\/code><\/li>\n\n\n\n<li>Use <code>find<\/code> command with an <code>alias<\/code> <\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"option-1-install-tree-tool-using-brew\"><span class=\"ez-toc-section\" id=\"Option_1_Install_tree_Tool_using_brew\"><\/span>Option 1: Install <code>tree<\/code> Tool using <code>brew<\/code><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Install using brew\nbrew install tree\n\n# Run the tree command\ntree<\/pre>\n\n\n\n<p>Here is an example:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/mutesoft.com\/spaces\/tech\/wp-content\/uploads\/sites\/4\/2022\/02\/tree-command-mac-1024x252.png\" alt=\"tree command output on Mac\" class=\"wp-image-670\"\/><figcaption class=\"wp-element-caption\">tree command output on Mac<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"option-2-use-find-command-with-an-alias\"><span class=\"ez-toc-section\" id=\"Option_2_Use_find_Command_with_an_Alias\"><\/span>Option 2: Use <code>find<\/code> Command with an Alias<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Alternatively, use the following <code>find<\/code> command to display files and folders in a tree view. For faster access, add this command as an alias to either <code>~\/.bashrc<\/code> (for BASH) or <code>~.\/zshrc<\/code> (for ZSH) depending on which shell you are using. I prefer this option since there is no additional installation required.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Command to display tree view\nfind . -print | sed -e 's;[^\/]*\/;|____;g;s;____|; |;g'\n\n# Add the above as an alias either in ~\/.bashrc or ~\/.zshrc depending on the shell you use\nalias tree=\"find . -print | sed -e 's;[^\/]*\/;|____;g;s;____|; |;g'\"\n\n# Run the tree command\ntree<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"tree-command-for-linux\"><span class=\"ez-toc-section\" id=\"Tree_Command_for_Linux\"><\/span>Tree Command for Linux<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Like Mac, Linux also does not come with a default <code>tree<\/code> command. Install <code>tree<\/code> before using it.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Install using yum\nyum install tree\n\n# Install using apt\napt-get install tree\n\n# Run the tree command in current directory\ntree\n\n# Run the tree command in a specified directory\ntree folder_name<\/pre>\n\n\n\n<p>Here is an example:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img decoding=\"async\" src=\"https:\/\/mutesoft.com\/spaces\/tech\/wp-content\/uploads\/sites\/4\/2022\/02\/tree-command-linux-1024x252.png\" alt=\"tree command output on Linux\" class=\"wp-image-671\"\/><figcaption class=\"wp-element-caption\">tree command output on Linux<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"tree-command-for-windows\"><span class=\"ez-toc-section\" id=\"Tree_Command_for_Windows\"><\/span>Tree Command for Windows<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Windows comes with a default <code>tree<\/code> command. In a command prompt, type the command <code>tree<\/code> to list files and folders in the tree view.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Run the tree command with \/F option to include files\ntree \/F<\/pre>\n\n\n\n<p>Here is an example:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/mutesoft.com\/spaces\/tech\/wp-content\/uploads\/sites\/4\/2022\/02\/tree-command-windows.jpg\" alt=\"tree command on Windows\" class=\"wp-image-664\"\/><figcaption class=\"wp-element-caption\">tree command output on Windows<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Tree command recursively lists files and folders in a tree structure. This provides an excellent overview of what a folder contains. On Windows tree command is available by default. However, there is no default tree command available on Linux and Mac. In this article, I&#8217;ll share steps to use tree command on Mac, Linux, and Windows.<\/p>\n","protected":false},"author":2,"featured_media":1094,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","_vp_format_video_url":"","_vp_image_focal_point":[],"footnotes":""},"categories":[32],"tags":[59,57,56,36,58],"class_list":["post-1090","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tools","tag-linux","tag-mac","tag-productivity","tag-tools","tag-windows"],"_links":{"self":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/1090","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/comments?post=1090"}],"version-history":[{"count":6,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/1090\/revisions"}],"predecessor-version":[{"id":1396,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/posts\/1090\/revisions\/1396"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/media\/1094"}],"wp:attachment":[{"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/media?parent=1090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/categories?post=1090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mutesoft.com\/spaces\/software\/wp-json\/wp\/v2\/tags?post=1090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}