Most recent file?

Most recent file?

Post by Jamie Web » Fri, 27 Dec 2002 12:33:50



Given two files which have the same modification time down to the second,
is it possible to tell which one was modified most recently?

I have a chain of 'make'-like scripts written in Perl: Script 1 builds
file B from file A, and script 2 builds file C from file B. So, if A is
modified, B and C are rebuilt in turn.

The problem is that the rebuilding process takes less than a second,
resulting in files B and C having the same modification time. Thus on the
next build, if A is not modified there is no way for script 2 (which is
not aware of file A) to tell whether or not file C needs to be rebuilt.
Even though the build is quick, I want to avoid doing it unnecessarily.

Any ideas?

TIA

 -- Jamie Webb

 
 
 

Most recent file?

Post by Juha Laih » Fri, 27 Dec 2002 19:12:02



Quote:>Given two files which have the same modification time down to the second,
>is it possible to tell which one was modified most recently?

No, all information you have is second-granularity timestamps.

Quote:>I have a chain of 'make'-like scripts written in Perl: Script 1 builds
>file B from file A, and script 2 builds file C from file B. So, if A is
>modified, B and C are rebuilt in turn.

>The problem is that the rebuilding process takes less than a second,
>resulting in files B and C having the same modification time. Thus on the
>next build, if A is not modified there is no way for script 2 (which is
>not aware of file A) to tell whether or not file C needs to be rebuilt.
>Even though the build is quick, I want to avoid doing it unnecessarily.

Apparently your logic should be based on the concept of building 'C' from
'A' - as this apparently is what you're doing. In the process you're
also getting an intermediate file, 'B', but that should be considered
a side issue.

So, to build 'C':
if ('C' does not exist) or ('A' is newer than 'C')
        if ('B' does not exist) or ('A is newer than 'B')
                build 'B'
        build 'C'

... no comparision between 'B' and 'C'. If 'B' itself is needed somewhere,
change the logic so that 'B' gets built if it is missing (in the above
case, 'B' may be missing, and will not be rebuilt, if 'C' is newer than
'A').
--
Wolf  a.k.a.  Juha Laiho     Espoo, Finland

         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)

 
 
 

Most recent file?

Post by Jamie Web » Fri, 27 Dec 2002 21:51:58



> Apparently your logic should be based on the concept of building 'C' from
> 'A' - as this apparently is what you're doing. In the process you're
> also getting an intermediate file, 'B', but that should be considered
> a side issue.

Yeah, trouble is, I simplified my description for clarity. In reality,
file A is an entire directory tree and file B is one of many files pointed
to by a manifest, which includes other files generated in different ways.
To bundle all that logic together would make a horrible mess.

 -- Jamie Webb

 
 
 

Most recent file?

Post by rnich.. » Sat, 28 Dec 2002 15:07:20




:
:> Apparently your logic should be based on the concept of building 'C' from
:> 'A' - as this apparently is what you're doing. In the process you're
:> also getting an intermediate file, 'B', but that should be considered
:> a side issue.
:
:Yeah, trouble is, I simplified my description for clarity. In reality,
:file A is an entire directory tree and file B is one of many files pointed
:to by a manifest, which includes other files generated in different ways.
:To bundle all that logic together would make a horrible mess.

Why not just consider C up to date if there is no file in set B with a
newer timestamp.  The only way that can fail is if you build C and then
modify something and rebuild a file in B less than one second later.
The fact that building C from B takes less than one second is of no
consequence.

The only other thought that comes to mind would be to embed version
numbers in the files, carry them through in the build process, and use
those to determine what is up to date.

--

 
 
 

1. finding recent files, duplicate files

(1) How can I list the last-modified files in my entire file system?
The command 'ls -ltR' lists files by date within each directory, but I
would like to list the files strictly by date, regardless of
directory. This is useful, because sometimes I forget which directory
I was working in! (I usually keep notes of this in a 'log' file.)

(2) I only recently learned how to create linked files. Thus, I have
many copies of the same file in different directories, for example
~/file.f and ~/new/file.f .
        (2a) How can I list all files with the same name
and the same contents, looking through my entire file system. I know
the diff command compares files.
        (2b) Also, how can I list all files with the same contents,
even if they have different names.
        (2c) The previous command, if possible, may be too slow, since
one compares every file to every other file. Can I compare all files
with the same suffix, such as .f for Fortran source files?

Thanks for your help. If you can answer any part of the questions
I asked, I would appreciate it.

______________________________________
Vivek Rao                            

http://www-ceg.ceg.uiuc.edu/~vrao/
Univ. of Illinois, Physics Department
______________________________________

2. MS Contributions to Science?

3. Files listing, how to list only the 10 most recent files

4. What does admintool do when adding a new client?

5. How do I get all but the most recent files into a variable?

6. Problem: fx_400 cdrom

7. finding recent files, minutes not days

8. Running process detection

9. How do I get all but the recent files?

10. Finding most recent file

11. Copy a most recent file

12. get the most recent file based on name and use it

13. find most recent file in a directory