× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello Don,

Am 31.01.2021 um 08:41 schrieb Don Brown via MIDRANGE-L <midrange-l@xxxxxxxxxxxxxxxxxx>:

Any suggestions gratefully accepted.

Knowing that the IBM tools always are a bit less blessed with features vs. the GNU tools, I'd recommend something like this:

for DIR in `find /test -type d -print |sort -r`; do
if [ `ls -a1 ${DIR} |wc -l` -eq 2 ]; then
rmdir ${DIR}
fi
done

In short:
- Create a list of all directories.
- Sort it backwards, so deepest levels come first (I assume IBM i find doesn't support -depth)
- Do a one-column directory content listing with all contents. In case of an empty directory, this should list exactly two entries: . and ..
- If there are only two entries, we can safely assume, the directory is empty and delete.

Untested, just out of my head! It assumes that there are no directories with spaces inside their names.

HTH.

:wq! PoC


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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

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.