Обратите внимание, что pwd
на самом деле является встроенной оболочкой. В зависимости от вашей оболочки и ее конфигурации результаты могут измениться. Для более портативного решения следует использовать /bin/pwd
. Фрагмент из страницы руководства:
NAME
pwd - print name of current/working directory
SYNOPSIS
pwd [OPTION]...
DESCRIPTION
Print the full filename of the current working directory.
-L, --logical
use PWD from environment, even if it contains symlinks
-P, --physical
avoid all symlinks
--help display this help and exit
--version
output version information and exit
If no option is specified, -P is assumed.
NOTE: your shell may have its own version of pwd, which usually supersedes the version described here. Please refer to your shell's documentation for
details about the options it supports.
В общем, вы можете определить полный канонический путь к любому файлу/каталогу, используя readlink -f
. readlink -f .
работает аналогично pwd -P
.