Compact Directory Listing Commands

Problem

The classic DIY tree command (find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g') outputs too much — shows every file including hidden metadata folders like .git and node_modules.

Solution: Progressive Filtering

tree -I 'node_modules|.git|cache' -L 2

Option 2: Ultra-Compact find

find . -maxdepth 2 -not -path '*/.*' \
    \( -name "node_modules" -o -name "bin" -o -name "obj" -o -name "venv" -o -name "target" \) -prune \
    -o -type d -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g' | tee project_summary.txt

Key flags:

  • -maxdepth 2 — Level 2 gives the “map,” Level 3 gives the “census”
  • -prune — stops find from entering heavy directories (not just hiding names)
  • -not -path '*/.*' — hides hidden files/folders (90% of clutter)
  • tee — displays on screen AND saves to file

Option 3: Summary View (No Tree)

du -h --max-depth=1 | sort -h

Shows which folders consume the most space — useful for identifying clutter sources.