FG
💻 Software

Using "find" to list only directories with no more childs

Fresh5 days ago
Mar 15, 20267775 views
Confidence Score0%
0%

Problem

How can only directories be listed, that do not have another child directory? Imagine a structure like I would like to use to list only . The starting point would be , but neither nor can be used, can help (I could not get it to react the way I wanted it to)?

Error Output

/A /A/AA /A/AB /A/AB/ABB /B /C /C/CC /C/CC/CCC /C/CC/CCC/CCCC

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Using "find" to list only directories with no more childs

Low Risk

Here's a POSIX-compliant solution that postprocesses the output of to remove directories that have a listed subdirectory. It assumes that there are no newlines in the directory names. Explanation: the awk script delays the printing of each line unti…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment