Answer» hi,
Please guide me what is the command to get the latest date of the files that is equal the directorie date
ex: the directoriy date of abc is 12 feb 2008 in abc directory the files and the dates are below 10 feb 2008 a.txt 11 feb 2008 b.txt 15 feb 2008 c.txt
by using which command or function to get abc directory date will GIVE as 15 feb 2008 i don't understand. please describe more clearly. your abc directory date is 12 Feb, but there's no files like that with 12 Feb.take this real time example....
here directory date is nov 20 2007
where as the file dates are nov 21 2007
drwxrwsr-xNov 20 2007/programs/postanalysis/output -rw-rw-r--Nov 21 2007/programs/postanalysis/output/a.wmf -rw-rw-r--Nov 21 2007/programs/postanalysis/output/a.doc
thanks, muddasaniI need to explain the filesystem structure so that you can understand why it appears like it does.
Every object has at least 3 dates associated with it: creation time, modify time, and last accessed time, maybe attribute change time too. These are STORED in what's called an inode. The inode contains a flag which identifies if the object is a file or directory (or other things) and the block address(es) of the data.
What's important to note is that a directory data block only contains the filename and its inode address.
When you create/copy a file, rename/move a file or delete a file you will update the modification time of the directory because you've had to add, edit or REMOVE entries from the directory.
However, in your case the files a.wmf and a.doc were created on or before 20 Nov 07, and then they were editted on 21 Nov 07. The point is that the filenames a.wmf and a.doc were not renamed on 21 Nov 07 so that's why the directory wasn't modified.
If you want to find the last modify time of any file WITHIN a directory (but not sub-directories) then you could do
cd /programs/postanalysis/output ls -lat | tail +2 | head -1
Finding the last modify time of a file anywhere in a directory tree WOULD have to involve some combination of find and sort, but that's not so easy to write off the top of my head.
|