On 2023-09-12 Peng Yu <pengyu...@gmail.com> wrote: > Hi, > How to find directories that only contain a certain type of files (e.g., > .txt)?
> One idea that I have is to just search for all files' paths. Then use > a post-processing script to analyze which directories only contain > files of a certain type (e.g., .txt extension). > Does anybody have a better idea of how to do this search? find -name '*.txt' -printf '%h\n' | sort -u (Actually you should use \0 and sort -u --zero-terminated and work on that nul-terminated list.) cu Andreas