Dot files always first in directory?

J. William Claypool jwc at unify.UUCP
Sat May 6 05:41:30 AEST 1989


In article <2778 at buengc.BU.EDU> bph at buengc.bu.edu (Blair P. Houghton) writes:
>In article <3540 at udccvax1.acs.udel.EDU> conan at vax1.acs.udel.EDU (Robert B Carroll) writes:
>>In article <11108 at bloom-beacon.MIT.EDU> jik at athena.mit.edu (Jonathan I. Kamens) writes:
>>>It it safe to assume when writing a program which manipulates
>>>directories that . and .. will always be the first two entries in a
>>>directory?
>>
>>NO, its not save to assume that.
>>try "touch #abcd" then 'list' the directory.
>
>To beat this horse quite dead, any leading character that would sort before
>the period will place the filename before the . and .. in a directory
>listing.  The ascii characters that will do this are space, !, ", #, $, %,
>&, ', (, ), *, +, ,, and -.  I haven't tried it, but I bet you can get the
>nonprinting ascii characters to do it too.  There are 32 of those.

All of this has nothing to do with the order of directory entries.
The 'ls' command sorts the directory entries according to the options
before displaying them.  The default sort order is alphabetical by name.

I suspect that . and .. will always be first in the directory
(unless you somehow manage to remove them) since they are created
as the first two entries by the mkdir(2) system call.

-- 
Bill Claypool		(916) 920-9092
jwc at unify.UUCP
{{ucdavis,csun,lll-crg}!csusac,pyramid,sequent}!unify!jwc



More information about the Comp.unix.wizards mailing list