1832995 Members
2218 Online
110048 Solutions
New Discussion

scripting question

 
SOLVED
Go to solution
Pieter_5
Advisor

scripting question

Hi,

I want to determine if file a has create on the same time as file b. Is there a easy way to do this in th korn shell?
4 REPLIES 4
G. Vrijhoeven
Honored Contributor

Re: scripting question

Hi,

You can use ls -clt.

Gideon
Leif Halvarsson_2
Honored Contributor
Solution

Re: scripting question

There is two tests in ksh

file1 -nt file2
True, if file1 exists and is newer than file2.

file1 -ot file2
True, if file1 exists and is older than file2.

What happens if the two files is created at exact the same time ? I don't know but try with both tests on the same files. If both tests returns false the files is created at the same time.
Michael Schulte zur Sur
Honored Contributor

Re: scripting question

Hi,

there is no foolproof way to check the creation date of a file.
ls -lc works as long as you don't change the inode with chmod or so.
Otherwise you have only the last modification date.

greetings,

Michael
A. Clay Stephenson
Acclaimed Contributor

Re: scripting question

Actually this is impossible because UNIX has no notion of when a file was created; that datum is not carried in the inode. If you know a file's creation time it is purely by accident. The 'ctime' of a file refers not to creation time but rather 'change' time --- which is not the same as 'mtime' (modification) time. 'Ctime' refers to the last mode change.
If it ain't broke, I can fix that.