🖥️tree
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the tree command with important options and switches using examples.
3 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ████████╗██████╗ ███████╗███████╗
# ╚══██╔══╝██╔══██╗██╔════╝██╔════╝
# ██║ ██████╔╝█████╗ █████╗
# ██║ ██╔══██╗██╔══╝ ██╔══╝
# ██║ ██║ ██║███████╗███████╗
# ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝
# To display a recursive directory tree
tree
# To make tree output contents from path `/foo/bar`
tree /foo/bar
# To make tree omit any empty directories from the output
tree --prune
# To list directories only (`-d`), and at a max depth of two levels (`-L`)
tree -d -L 2
#==============================#
# CMD TREE
#==============================##==============================#
tree | convert label:@- /home/avi/tree.png
# While writing tutorial, I usually need to produce output, many a times in image format. The above command combination does this for me. Say I need the output of tree command (for /etc/x11 directory) in image format.
tree -fash
# Ordnerstruktur in Baumansicht mti Größenangabe pro File
tree -isafF | grep -v /$ | sort -k2nr | head
# Etws umfangreicher, aber die ausgabe nach Byte sortiert kann sich sehen lassen
#jump to home dir and list all, not older than 3 days, with full-path, hidden/non-hidden files/subdirectories
# Number of days back: change/append arbitrary amount of '\|'$[$(date +%Y%j)-x] expressions or specify any n-th day before today for a single day (you have to replace x with 3, 4, 5, whatever ... above I replaced it with 1 and 2 to get listing for yesterday and day before yesterday and 0 for today was not necessary, so left out). Q: How to narrow to *.pdf , *.png, *.jpg, *.txt, *.doc, *.sh or any type of files only? A: Pipe to grep at the end of command. Even shorter: cd && day=3;for a in $(seq $day -1 0);do tree -aicfnF --timefmt %Y%j-%d-%b-%y|grep $[$(date +%Y%j)-$a];done Here it's only needed to change amount of variable day to list period of days back - here is set to three days back (the seq command is adjusted for listing the oldest stuff first).
cd && tree -aicfnF --timefmt %Y%j-%d-%b-%y|grep $(date +%Y%j)'\|'$[$(date +%Y%j)-1]'\|'$[$(date +%Y%j)-2]
#This is sample output - yours may be different.
[2019215-03-Aug-19] ./.config/session/
[2019215-03-Aug-19] ./.config/session/konsole_2b5b0f704-9942-428b-a3d8-8054efd32b18_1564837706_57870
[2019215-03-Aug-19] ./.config/session/konsole_23e1f9567-a8ff-42ad-a879-76f7bafb56c3_1564840981_89854
[2019215-03-Aug-19] ./.config/session/konsole_2e2aea661-fd41-4510-b0b9-1d2c69ef99c7_1564864156_611707
[2019215-03-Aug-19] ./.config/konsolerc
[2019216-04-Aug-19] ./.config/dconf/
[2019216-04-Aug-19] ./.config/dconf/user
[2019216-04-Aug-19] ./.config/briši_me.pdf
#==============================##==============================#
# CMD TREE
#==============================##==============================#
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command tree in a clear format. This allows users to quickly access the needed information for tree without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for tree are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.