List all leaf subdirectories in linux
bash
Solution
find . -type d | sort | awk '$0 !~ last "/" {print last} {last=$0} END {print last}'
Problem
Is there an easy way to list only directories under a given directory in Linux? To explain better, I can do: ``` find mydir -type d ``` which gives: ``` mydir/src mydir/src/main mydir/bin mydir/bin/classes ``` What I want instead is: ``` mydir/src/main mydir/bin/classes ``` I can do this in a bash script that loops over the lines and removes previous line if next line contains the path, but I'm wondering if there is a simpler method that does not use bash loops.