> Hi. > > On Thu, 29 May 2014 14:31:03 -0500 > Dennis Wicks <w...@mgssub.com> wrote: > > > Can't quite figure out how to do this. > > > > I'd like to be able to scan a Volume or directory and find > > all directories that have only one item in them. Either > > directory or file. > > Try this (yep, links should be 3, not 1): > > find <where_you_want_to_search> -type d -links 3 > > Reco
That looked neat (just a single process) but it doesn't quite answer the question. It finds directories containing exactly one subdirectory and any number of other files. clive@rimmer:~$ find temp -type d -links 3 | xargs -r ls -A1F temp/for-brum/notes: general/ temp/here: sub-here/ temp/offlineimap-dummy-config: .mutt/ .offlineimaprc .offlineimaprc.~1~ temp/stuff: a/ temp/stuff/a: b/ xyz temp/there: sub-there/ A different approach: find everything, strip off the leaf entry and filter out duplicate parent dirs: find temp |sed 's|[^/]*$||' |sort |uniq -u For example: clive@rimmer:~$ find temp |sed 's|[^/]*$||' |sort |uniq -u | xargs -r ls -A1F temp/for-brum/notes/: general/ temp/for-brum/usbmount/mount.d/: 00_create_model_symlink* temp/for-brum/usbmount/umount.d/: 00_remove_model_symlink* temp/here/: sub-here/ temp/here/sub-here/: extra-here temp/plates/clive-favourites/: clive-favourites.control.template temp/plates/clive-mail-client/: clive-mail-client.control.template temp/plates/clive-mail-local-delivery/: clive-mail-local-delivery.control.template temp/plates/clive-mail/: clive-mail.control.template temp/stuff/: a/ temp/there/: sub-there/ temp/there/sub-there/: extra-there PS the sort is probably unnecessary, just being careful. -- Cheers, Clive -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: https://lists.debian.org/20140529214320.GA9259@rimmer.localdomain