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



Thank you for that very clear post.  I am planning on using this for 
cleaning up my Domino server's IBM_TECHNICAL_SUPPORT directory.  This 
normally contains debug type files.

Rob Berendt
-- 
Group Dekko Services, LLC
Dept 01.073
PO Box 2000
Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com





Scott Klement <midrange-l@xxxxxxxxxxxxxxxx> 
Sent by: midrange-l-bounces+rob=dekko.com@xxxxxxxxxxxx
01/27/2005 06:26 PM
Please respond to
Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>


To
Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
cc

Subject
Re: QSHELL's ls command







> Tried doing a STRQSH and then a ls -? to find the parameters.  Not 
nearly
> definitive as DOS help, eh?

On a Unix system (not the iSeries) you'd normally get help on any command 
by typing "man ls" (or whatever the command happens to be) the resulting 
help screen is MUCH more informative than the MS-DOS version.

<rant>
Try finding out what to pass to "NET SEND" on Windows if you're not 
already familiar with the parameters!!!

C:\WINDOWS>net send /?
The syntax of this command is:

NET SEND
{name | * | /DOMAIN[:name] | /USERS} message

Gee, thanks. And this is the only help I'm aware of for this command...
</rant>

Anyway, the iSeries doesn't have the Unix manual on-line.  Instead, you 
have to go to the Information Center to get help on QShell commands.

Programming -> Shells and Utilities -> QShell -> Utilities -> L -> ls


> What I want to do is pipe the listing of ls through whatever their 
version
> of DEL is.  However I was wondering if there was some selection criteria
> on the ls command that would say files that have a last modified date x
> days old.

The Unix equivalent of "DEL" is "rm" (remove).  But the PIPE sends data to 

it's standard input stream, and "rm" deletes files based on it's 
parameters, not it's standard input.  Fortunately, there's a utility that 
converts standard input to a parameter list called "xargs". What it does 
is read the standard input and use it to create a command string. 
Whatever you specify as xargs' parameters will be added to the start of 
the command string.

So, the following command would try to run the QShell command line "foo 
bar":
   echo "foo" | xargs bar

The 'ls' utility won't list files based on age, but the 'find' command 
will.  For example, to delete files (but not directories) under the 
/home/scott directory that haven't been modified in 10 days, you could 
type:

   find /home/scott -type f -mtime +10 | xargs rm

For testing purposes, I'd recommend typing

   find /whatever -type f -mtime +10

to make sure it gives you the output that you're expecting.  Then add the 
'xargs rm' to the end when you're sure it's only going to delete the right 

stuff.

The other problem you may run into is the maximum length of a single 
command string.  If there are a million files that need to be deleted, it 
won't all fit on a single command line generated by xargs.

If that happens, you can tell QShell to launch a separater "rm" for each 
command.  It will take a LOT longer, but it'll work:

   find /home/scott -type f -mtime +10 -exec rm {} \;

the -exec switch tells it to execute a command.  Everything after the 
-exec and before the semi-colon is considered a part of the command it 
executes.  The braces "{}" will be replaced with each filename for each 
file that it wants to delete.  The backslash is needed to escape the 
semi-colon so that it'll get passed to the find utility rather than being 
interpreted by Qshell itself.

But, like I said, using -exec is very inefficient on computer resources 
because it submits a separate job for each file that you want to delete, 
whereas the xargs version submits only one job that deletes them all.

Of course, if you really need the ability to delete an unlimited number of 

files, you could redirect the output of "find" to a physical file member, 
and have a CL program that reads that member and deletes each file with 
the RMVLNK command.  That would also be more efficient than -exec...

Okay, I've said enough for now :)

-- 
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing 
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



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.