Skip to content

Instantly share code, notes, and snippets.

@tasiot
Created July 18, 2022 16:56
Show Gist options
  • Save tasiot/0dc6b69748c07896445520b0d49489ae to your computer and use it in GitHub Desktop.
Save tasiot/0dc6b69748c07896445520b0d49489ae to your computer and use it in GitHub Desktop.
List all folders as tree

List all folders as tree (found at https://stackoverflow.com/a/3455651/9418252)

.
|-apache2
|---mod_cache_disk
|-apparmor
|-apt
|---archives
|-----partial
|-apt-xapian-index
|---index.1
|-dbconfig-common
|---backups
|-debconf

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'

Tree with files

find . | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment