Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ucsd!sdcsvax!ucsdhub!sdsu!csun!csusac!unify!jwc From: jwc@unify.UUCP (J. William Claypool) Newsgroups: comp.unix.wizards Subject: Re: Dot files always first in directory? Message-ID: <748@unify.UUCP> Date: 5 May 89 19:41:30 GMT References: <11108@bloom-beacon.MIT.EDU> <3540@udccvax1.acs.udel.EDU> <2778@buengc.BU.EDU> Reply-To: jwc@unify.UUCP (J. William Claypool) Organization: Unify Corporation, Sacramento, CA, USA Lines: 28 In article <2778@buengc.BU.EDU> bph@buengc.bu.edu (Blair P. Houghton) writes: >In article <3540@udccvax1.acs.udel.EDU> conan@vax1.acs.udel.EDU (Robert B Carroll) writes: >>In article <11108@bloom-beacon.MIT.EDU> jik@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@unify.UUCP {{ucdavis,csun,lll-crg}!csusac,pyramid,sequent}!unify!jwc