|
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
removed.
for DIR in `find . -depth -type d`; do
if [ `ls -1a ${DIR} |wc -l` -eq 2 ]; then
rmdir ${DIR}
fi
done
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,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com 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.