2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Absolute path:
C:UsersUsernameDocumentsfile.txt
。
。relative path:
.
Indicates the current directory,..
Indicates the parent directory.C:UsersUsername
,but Documentsfile.txt
Equivalent toC:UsersUsernameDocumentsfile.txt
。C:UsersUsername
,but .Documentsfile.txt
Equivalent toC:UsersUsernameDocumentsfile.txt
。Absolute path:
/usr/include/stdio.h
。/
。relative path:
.
Indicates the current directory,..
Indicates the parent directory./usr
,but include/stdio.h
Equivalent to/usr/include/stdio.h
。Path separator:
, Linux uses forward slashes /
。Path resolution:
usage habit:
"./user/test.sh" is equivalent to "user/test.sh"
The presence or absence of a dot in the path usually has no effect, especially in most modern operating systems and command line environments. This is because:
Default current directory: When you specify a relative path, the system will default to looking for the file or directory in the current working directory. So, Documentsfile.txt and .Documentsfile.txt point to the same file location in most cases.
Display the current directory: Sometimes, in order to clearly indicate the current directory, or to avoid confusion in complex commands, . is used explicitly. Doing so can improve the readability of the code and the clarity of the command.
Cross-platform adaptability: In cross-platform development or scripting, explicitly using . ensures that path separators are interpreted correctly on different operating systems. For example, use on Windows and / on Unix or Linux.
In general, whether to use . depends on personal or team preference and coding standards. In most cases, the system automatically handles relative paths.Therefore, . is not required, but it can help clarify the starting point of the path.