bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to find directories that only contain a certain type of files (e


From: Andreas Metzler
Subject: Re: How to find directories that only contain a certain type of files (e.g., .txt)?
Date: Tue, 12 Sep 2023 18:39:32 +0200

On 2023-09-12 Peng Yu <pengyu.ut@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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]