I'm looking to create a list of directories that contain files of a certain type, such as .mp3 files. I've got it mostly working with this command:
Code:
find . -name "*.mp3" -printf "%h\n"|sort -u
The problem is that it also lists parent directories as well. For example, "./dira/dirb/dirc/song.mp3" would give me
./dira
./dira/dirb
./dira/dirb/dirc
I only want the last entry. Is there any simple way to filter out the unwanted ones?
Note that sometimes the parent directories can contain files as well, so I can't just remove partial duplicates from the list after it's compiled (i.e. there are times when ./dira/dirb would also be a legitimate hit).