Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

After reading this question Design question: Why was '~' chosen to represent the home directory?, next obvious question on my mind was why '.' and '..' was used to represent current directory and parent directory.

It seems so intuitive now, but any particular reason?

share|improve this question
4  
That questions has been asked and answer on SO –  Stephane Chazelas Jan 21 '13 at 16:09
add comment

1 Answer

I doubt you are going to find as interesting an answer as to the tilde question!

I was not there, but .. is like an ellipsis (...), which makes sense in contexts like cd ../../../there. Also, and especially looking at ye olde terminal keyboard from the tilde case, there are not many eligible characters for this purpose. You don't need to shift for ., either. It's perfect.

The fact that a dot prefix is used for hidden files might be another reason. Hidden files are not listed by default by tools such as ls, so neither are the essentially redundant . and ... Redundant in the sense that there is no point considering them along with other files -- they are certainly useful otherwise.

As it turns out I may have it backwards...from wikipedia:

The notion that filenames preceded by a '.' should be hidden is the result of a software bug in the early days of Unix. When the special '.' and '..' directory entries were added to the filesystem, it was decided that the ls command should not display them. However, the ls program was mistakenly written to exclude any file whose name started with a '.', rather than only files named '.' or '..'.

This does turn out to be useful when programming; since the system does include . and .. in response to readdir() type commands (and shell globs), ignoring them and hidden files can be accomplished the same way.

A different opinion about that use value is in the reference for the wikipedia quote. Of course, the whole story could be apocryphal...it is a little hard to believe that eg, Dennis Ritchie figured just checking for the first character would be okay.

I disagree with the author vis, it would be better to put hidden configuration files in their own directory rather than give them a universal prefix. The prefix is much more flexible, allowing for in-tree directives like .gitignore and .htaccess. Witness that files of that sort also appear together when sorted lexicographically -- so perhaps this was on purpose after all.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.