What does "/" , "./", "../" represent while giving path?
migrated from stackoverflow.com Jun 16 '10 at 11:33
|
Root directory, current working directory, and parent directory, respectively. |
|||
|
|
|
|
|||
|
|
|
|||
|
|
|
Let's be precise: "/"is a path which begins with a /, and thus it is an absolute path. Thus, we need to begin in the root of the file system and navigate through the folders given by name, whereas the names are separated by /s (because this is the unix path separator). ./ does not begin with a /, and thus ./ cannot be an absolute file name. Thus, it is a relative file system name. Thus, we need to start with the current working directory and apply the navigation operations which are separated by the path separator again. In this case, the operation is ".", which means: stay in the current folder. (Thus, one has to type ./foo in order to execute foo in the current directory, if . is not in the path-variable). After the "stay in the current folder", nothing further happens, so ./ describe the current working directory. Given the knowledge that .. means: go to the parent folder, ../ should be easy to deduce and is left as an exercise. |
|||
|
|
|
the slash if a path starts with a slash, it means it's the root of the filesystem. if you omit the slash in the beginning |
|||
|
|