07-08-2015 11:34 AM
What determines the sequence number of some file in some directory (UNIX)?
I wanted to use DREAD(&dir,1) to read the filename of the first file in the direcotry in alphabetical order, but it doesn't work since the sequence is not alphabetical and also not date or file size. But what is it then?
The documentation for the DREAD function only says:
is a numeric constant, variable, or expression that specifies the sequence number of the member within the directory.
I think there should be some information on what the sequence number actually is.
07-08-2015 03:11 PM
Here is a page with programs for making lists.
make the list of filenames then sort by filename.
I have no idea where the nval value is assigned.
This is similar to the order of macro variables: makes no obvious sense.
07-08-2015 03:57 PM
Use Dnum for the number of members and loop over the value 1 to dnum to get the name for each numbered file in a data set. Then use that to get other characteristics, sort and process by the sorted order.
I don't know the Unix file system well enough but I suspect there is a reason for order. And which date did you look at? Was it a date updated, created, read, "touched" or something else?
07-09-2015 07:02 AM
Thanks Ron and ballardw for the hints. Actually I solved my problem in a similiar way. I am just curios how DREAD works - also to use it as it is and not with some workaround.
Date was date updated and I just checked that it's not date created. As it really seems arbitrary my guess would be that it uses the order on the hard drive, i.e. the order in which files in the direcotry are read.
PS: Does someone know the guy who implemented this function? I guess he or she knows ;-)