[Linux-disciples] find(1) to find only leaf nodes?

Dylan Thurston dpt at math.columbia.edu
Thu Feb 12 15:44:33 EST 2009


On Thu, Feb 12, 2009 at 11:08:17AM -0500, Stephen R Laniel wrote:
> I was hoping there would be a -leaf
> argument to find(1), which would return
> only those elements of the filesystem
> tree that have no children. That would
> mean either
> 
> - non-directories ("-not -type d"), or
> - directories with no children

dpt at amaryllis:/tmp$ find test -not -type d -or \( -type d -and -empty \)
test/a
test/b/c
test/b/d
test/b/e
dpt at amaryllis:/tmp$ ls -R test
test:
a  b

test/a:

test/b:
c  d  e

test/b/d:


More information about the Linux-disciples mailing list