Created
February 12, 2025 10:44
-
-
Save TTy32/4b66351dde364af54b01ca7a4dd7df02 to your computer and use it in GitHub Desktop.
tree: limit number of files for each directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tree -L 3 | awk ' | |
BEGIN { | |
last_prefix = "" | |
count = 1 | |
} | |
{ | |
# Extract indentation | |
prefix = $0 | |
sub(/[^│├└─]+$/, "", prefix) | |
if (count < 5) { | |
} | |
if (prefix == last_prefix) { | |
count++ | |
} else { | |
if (count > 5) { | |
print prefix " " count " more files..." | |
} | |
count = 1 | |
} | |
last_prefix = prefix | |
}' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Produces: