-since option for ls -lt

Leo de Wit leo at philmds.UUCP
Sun Jun 12 21:10:27 AEST 1988


In article <344 at ajpo.sei.cmu.edu> jrkelly at ajpo.sei.cmu.edu (John Kelly) writes:
>In VMS and TOPS-20, the directory listing commands have a /since option that
  [stuff deleted]
>Has anyone implemented any of the following for Unix:
>
>  1. a directory listing command with a -since option?
>  2. a program to force a specified modification time upon a specified file?
>  3. a program to compare two dates/times and return an appropriate status?
>
>where the dates/times are given in string form, as in the output of "date" and
>"ls"?

1. Is easy. You were on the right way. Use 'find' with the '-mtime' option.
In this way you can also have your /before qualifier (yes, I'm also deemed to
use Very Mediocrate System now and then 8-). You even have a /at qualifier!
    Example:

    ls -l `find . -mtime -7 -print` # files modified since last week
(could also use find with -exec ls -l {}, but that's much slower). Note that
find does recursively descend the directory structure. There is also a -atime
option to match on access time if you're interested.
2. That's also easy. I've created a file older than any computer and one
in the next century doing that. You can use the utimes() system call; it is
in the Ultrix system.
3. There's a standard Un*x program that compares dates/times (of files that
is); it is called make. You can use make for much more than only software
generation. Use you imagination.
If you want the time(s) of a file, use stat() (or fstat()).
You can of course use find to compare dates/times of files:
find . -name secondname -newer firstfile -print
prints secondname if it is new than firstfile. The usefulness of string form
dates/times I don't quite see, being perfectly happy with -mtime -7 and the
like.

	Leo.



More information about the Comp.unix.questions mailing list