× 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.



Hi Dennis,

Dennis Lovelady wrote:
Two things: 1) I don't know how that find syntax got so popular! You might consider
changing for readability
2) If $1 will contain blanks (and you say it will) then you're going to
need quotes also in the script.

Hmmm... not sure that I agree with that first point, and your solution won't work for #2.

Here's my rewritten line:
rm -d $(find "${1}" -mtime +${2})

Two problems with this.

1) Earlier versions of QShell (prior to v5r3 if I remember correctly) only supported 255 parameters to a program. Since your 'find' could easily output more than 255 filenames, you have a problem. That limit was expanded to 65535 in newer releases, but there's still a chance of having more than that many files found by the 'find' utility -- plus you risk hitting the 16 MB limit on the size of a command-line.

2) Just because you put quotes on the call to 'find' doesn't mean that the OUTPUT from 'find' will have quotes on it! In this case, if find outputs files named
lovely file1.ext
lovely file2.ext

You'll have constructed a command like:
rm -d lovely file1.ext lovely file2.ext

and it'll fail because there is no file named lovely. (or file1.ext. Or.. or...)

I have on MANY occasions told people that there's two ways to do this. Use 'find' with -exec, which is simple and takes one line, but is horribly inefficient, or to use 'find' to output to something else that deletes the files in a loop. More code, but much more efficient.

Somehow the simple one gets passed from person to person, and the efficient one gets consistently ignored.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.