[英]No man page for the cd command
Ubuntu Linux 15.10 - 我剛剛注意到cd
沒有手冊頁
這似乎有點奇怪。
我試過:
man cd
在 cmd 行,我回來了
No manual entry for cd
我試圖找到有關的文檔
cd -
這對於在最后一個目錄和當前目錄之間翻轉非常方便
和cd --
這似乎是一個別名
cd ~
我在這里遺漏了一些非常明顯的東西,還是應該提供手冊頁?
cd
不是命令,它內置於您的 shell 中。 這是必要的,因為您當前的工作目錄由以pwd
或“打印工作目錄”命令命名的PWD
環境變量控制。
子進程不能更改父進程的環境變量。 因此,如果您的 shell 運行/bin/cd
更改了PWD
它只會影響/bin/cd
及其運行的任何內容。 它不會改變外殼的PWD
。
某些系統,如 OS X 和 CentOS,將cd
手冊頁映射到builtin
,其中列出了所有 shell 內置程序,並讓您知道應該查看 shell 的手冊頁。
您可以使用echo $SHELL
檢查您擁有的echo $SHELL
,它可能是bash
。
cd
是一個內置的 shell 命令。
$ type cd
cd is a shell builtin
您可以在 Bash 上打開cd
的幫助頁面
$ help cd
目前顯示(Ubuntu 16.04):
$ help cd
cd: cd [-L|[-P [-e]] [-@]] [dir]
Change the shell working directory.
Change the current directory to DIR. The default DIR is the value of the
HOME shell variable.
The variable CDPATH defines the search path for the directory containing
DIR. Alternative directory names in CDPATH are separated by a colon (:).
A null directory name is the same as the current directory. If DIR begins
with a slash (/), then CDPATH is not used.
If the directory is not found, and the shell option `cdable_vars' is set,
the word is assumed to be a variable name. If that variable has a value,
its value is used for DIR.
Options:
-L force symbolic links to be followed: resolve symbolic links in
DIR after processing instances of `..'
-P use the physical directory structure without following symbolic
links: resolve symbolic links in DIR before processing instances
of `..'
-e if the -P option is supplied, and the current working directory
cannot be determined successfully, exit with a non-zero status
-@ on systems that support it, present a file with extended attributes
as a directory containing the file attributes
The default is to follow symbolic links, as if `-L' were specified.
`..' is processed by removing the immediately previous pathname component
back to a slash or the beginning of DIR.
Exit Status:
Returns 0 if the directory is changed, and if $PWD is set successfully when
-P is used; non-zero otherwise.
不幸的是,它沒有回答您的問題。 有文檔,做不過來。
你可以用
$ man builtins
它使用我的默認查看器less
打開許多幫助頁面。 我可以通過按/
鍵找到 cd 的幫助,然后輸入cd
,然后Enter
,然后按兩次n
可以找到子字符串的第三個實例,幫助內容如下:
cd [-L|[-P [-e]] [-@]] [dir]
Change the current directory to dir. if dir is not supplied,
the value of the HOME shell variable is the default. Any addi‐
tional arguments following dir are ignored. The variable CDPATH
defines the search path for the directory containing dir: each
directory name in CDPATH is searched for dir. Alternative
directory names in CDPATH are separated by a colon (:). A null
directory name in CDPATH is the same as the current directory,
i.e., ``.''. If dir begins with a slash (/), then CDPATH is not
used. The -P option causes cd to use the physical directory
structure by resolving symbolic links while traversing dir and
before processing instances of .. in dir (see also the -P option
to the set builtin command); the -L option forces symbolic links
to be followed by resolving the link after processing instances
of .. in dir. If .. appears in dir, it is processed by removing
the immediately previous pathname component from dir, back to a
slash or the beginning of dir. If the -e option is supplied
with -P, and the current working directory cannot be success‐
fully determined after a successful directory change, cd will
return an unsuccessful status. On systems that support it, the
-@ option presents the extended attributes associated with a
file as a directory. An argument of - is converted to $OLDPWD
before the directory change is attempted. If a non-empty direc‐
tory name from CDPATH is used, or if - is the first argument,
and the directory change is successful, the absolute pathname of
the new working directory is written to the standard output.
The return value is true if the directory was successfully
changed; false otherwise.
尋找關於從末尾開始的第七行的-
參數:
在嘗試更改目錄之前,
-
的參數被轉換為$OLDPWD
。
請注意,沒有--
參數 - 這似乎意味着它實際上忽略了它。
bash 手冊頁的相關摘錄,涵蓋了cd -
使用cd -
cd [-L|[-P [-e]] [-@]] [dir]
Change the current directory to dir.
...
An argument of -
is converted to $OLDPWD before the directory change is attempted. If a non-
empty directory name from CDPATH is used, or if - is the first argument, and
the directory change is successful, the absolute pathname of the new working
directory is written to the standard output. The return value is true if the
directory was successfully changed; false otherwise.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.