× 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 Doug,

> I am trying to delete all the files AND directories older than 30 days below
> this path /edi4xxpgm/network/ix/ini but only got the files not the
> directories.  Error on directory not empty.  What have I got wrong?
>
> QSH
> find /edi4xxpgm/network/ix/ini -mtime +30 -exec rm -d {} \;

You can't delete directories that have files in them.  You have to delete
all of the files in them before you can delete the directory.

If you REALLY want the rm command to do that for you, you can pass the -r
switch to 'rm'. (WARNING: Make backups and do tests until you're sure
you've got it right!) For example:

    find /edi4xxpgm/network/ix/ini -mtime +30 -exec rm -r {} \;

>
> And, what does the {} mean?
>

The -exec option to the 'find' command can be used to run ANY command.  It
could be something included with QShell, or it could be a program that you
write, or a QShell script... it can run anything.

The way it does that is by constructing a command string for each file
that it finds, and executing that command string (again, once for each
file.)  the {} characters tell find where to insert the filename.

For example, if you wanted to have Qshell send a message to QSYSOPR for
each file that it finds, you could do:

find /path/to/mydir -mtime +30 -exec system sndmsg msg\(\'{}\'\) 
tousr\(qsysopr\) \;

(Since quotes and parenthesis are special characters in QShell, you have
to put a \ in front of them to "escape" them.)


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.