Path: utzoo!attcan!uunet!mcvax!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: -since option for ls -lt Message-ID: <503@philmds.UUCP> Date: 12 Jun 88 11:10:27 GMT References: <344@ajpo.sei.cmu.edu> Reply-To: leo@philmds.UUCP (L.J.M. de Wit) Organization: Philips I&E DTS Eindhoven Lines: 35 Xref: utzoo comp.unix.questions:7535 comp.unix.wizards:9263 In article <344@ajpo.sei.cmu.edu> jrkelly@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.