Thank you for this information. I have tested it and it is working for me.
To do an initial test I change rmdir to an echo.
Not very fluent in this scripting. trying to figure out the change so it
only searches the current level.

Thanks again.

On Sat, Oct 2, 2021 at 5:41 AM Patrik Schindler <poc@xxxxxxxxxx> wrote:

Hello K.,

Am 01.10.2021 um 17:41 schrieb K Crawford <kscx3ksc@xxxxxxxxx>:

This works. find /home/kcrawford -type d

I am open to other solutions.

A simple shell-script will do also. I assume there are no blanks in the
directory names!

Here, find generates a list of all directories starting from the current
directory, listing the most nested directories first (so directories
freeing directories can be probably identified as free, and deleted). For
every entry, a "ls" command prints *all* entries, line by line. An empty
directory has only two lines, two entries for . and .., so it's safe to
assume that a directory with only two entries is empty and can be safely

for DIR in `find . -depth -type d`; do
if [ `ls -1a ${DIR} |wc -l` -eq 2 ]; then
rmdir ${DIR}

Tested in qsh with 7.2, no error messages. Can be used as one-liner, or
saved in a *STMF with indents to help understanding at a later point in
time. :-)

Important! The backticks are *not* apostrophes! You may see these like a
braced expression in mathematics.

:wq! PoC

This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related

Help support by shopping at with our affiliate

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.