the purpose of directories "." and ".."
I recently had to use the Windows FindFirstFile/FindNextFile functions, and I noticed that directories "." and ".." kept appearing. What is the point of having these show up in the search? From what I understand (and this may be misinformation), these directories are simply the ones ''beneath'' the current one. I don''t see how this would be used in practice, can anyone explain their function to me, and inform me if I am somehow making a mistake by omitting them.
Thanks.
. refers to the current directory. In some shells, you use it to refer to a program in the current directory (./myprogram).
.. refers to the directory underneath the current directory. This is good if you want to start a program that is in the directory beneath your current directory without having to type in the full path (../myprogram2).
Those are just two examples, I''m sure there are more...
.. refers to the directory underneath the current directory. This is good if you want to start a program that is in the directory beneath your current directory without having to type in the full path (../myprogram2).
Those are just two examples, I''m sure there are more...
cd .. means change directory to the parent of the directory you are in. So, .. is the parent directory.
I also believe that a big reason for . is a holdover from UNIX. I could be wrong about this, but I BELIEVE that UNIX will look through your path before running a program from the current directory. So, if you are trying to run an executable called ''test'' but there is also an executable called ''test'' in the /etc/bin directory (or somewhere else in your path), you will end up running this other executable. If you want to run the one in the current directory, you just put ./test and you are sure that you are running the correct one.
Now, I could be wrong about this. I''m not a UNIX guru, but I believe that is how it works.
Now, I could be wrong about this. I''m not a UNIX guru, but I believe that is how it works.
Yeah, that''s how most UNIX shells behave. But it is of course possible to program a new shell which behaves like DOS'' command.com... Or simply put ./ before everything else in your PATH and voíla.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement