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



On Fri, 14 Oct 2005, Stefan Tageson wrote:

Hello Marty,
Perhaps you could use ls /QIBM/*.txt

Yes, I can - but one of the benefits of using find is that I can use
-atime/-ctime to only retrieve some of the files based on last
accessed/changed date.
I also guess that someone with more unix knowledge than me can combine
various of the shell commands to get similar results.

I decided to find out how this could be done using just unix commands. Unfortunately, I couldn't find a way to do it on iSeries because the commands in QSH are quite limited in comparison to the GNU commands available in linux and other unix-like OSes. So while this won't work on iSeries, it might be useful or at the very least interesting.

You can use the -u option to ls to sort by access time. When combined with the -lt options it will also show the access time. From the man page for ls:

       -u     with -lt: sort by, and show, access time  with  -l:
              show  access  time and sort by name otherwise: sort
              by access time

You can use the -c option in a similar way to the time of the last modification of file status information. Again from the ls man page:

       -c     with -lt: sort by, and show, ctime  (time  of  last
              modification  of  file status information) with -l:
              show ctime and sort  by  name  otherwise:  sort  by
              ctime

And of course the -t option by itself sorts by modification time (whereas -c deals with the modification of file status information).

So far this all works on the iSeries as well. But here is where we require the GNU options that the iSeries does not support. In order to get the times to display in numeric format only use the GNU option --full-time which outputs the times in ISO format. There may be a way to do this in QSH but I don't know what it is.

With the times in ISO format we are done with ls and ready to do something with the output to limit the list to just those files we are interested in. So far I've only been able to come up with a way to get files for a specific regexp pattern. In order to do something like 'greater than' I pretty sure you would have to write a little shell script. But we can get only those files with today's date using grep:

ls -ltur --full-time | grep 2005-10-14

With results similar to:

-rw------- 1 james users 2596 2005-10-14 11:17:10.267615196 -0600 dead.letter

Which gives us a list of files with possibly more information than you want. We have to use the -l option to ls in order for grep to work so we can't leave that off to reduce the amount of output. But we can use awk to print out just the file names:

ls -ltur --full-time | grep 2005-10-14 | awk '{print $9}'

Now we print out just the ninth column of data resulting in:

dead.letter

I'm sure there are more things you could do. Maybe porting the GNU commands wouldn't be a bad idea... :)

James Rich

It's not the software that's free; it's you.
        - billyskank on Groklaw

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.