2016-12-14 2 views
3

Ubuntu Linux 15.10 - я просто не заметил, что нет ни одного человека, страница cdНи один человек страница для команды кд

Это кажется немного странным.

Я пробовал:

man cd 

на CMD линии, и я вернусь

No manual entry for cd 

Я пытался найти документацию по

cd - 

который является супер-удобно для листать между последним источником тока и токовым портом

и cd --

, который, как представляется, является псевдонимом для

cd ~ 

Я пропускаю что-то очень очевидное здесь, или если страница человек будет присутствовать?

ответ

6

не является командой, она встроена в вашу оболочку. Это необходимо, потому что текущая рабочая директория управляется переменной окружения PWD, названной в честь команды pwd или команды «print working directory».

Переменные окружения родительского процесса не могут быть изменены дочерним процессом. Так что если ваша раковина побежала /bin/cd, которая изменила PWD, это повлияло бы только на /bin/cd и все, что она побежала. Это не изменило бы PWD.

Некоторые системы, такие как OS X и CentOS, сопоставляют справочную страницу cd с номером builtin, в котором перечислены все встроенные оболочки и вы знаете, что вы должны посмотреть на страницу руководства вашей оболочки.

Вы можете проверить, какая у вас раковина echo $SHELL, это, вероятно, bash.

+1

Я нашел некоторую ссылку на cd сейчас на странице man bash - спасибо за информацию, узнал что-то здесь. – bph

-2

соответствующая выдержка из Баша человек страницы сопроводительным использования cd -

 cd [-L|[-P [-e]] [[email protected]]] [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. 
+0

Вопрос в том, почему man-страница не существует и где она находится. Вставка в разделе «cd» не является хорошим ответом, и она применима только к этой конкретной оболочке. Да, я понимаю, вы задали вопрос. – Schwern

+0

это немного помогает с частью OP по документации cd - опции, похоже, не упоминается cd - хотя .. Интересно, действительно ли это псевдоним для cd ~? – bph

+1

'--' - общий способ сказать« конец опций », все последующее будет файлом или аргументом. Это удобно для работы с файлами, начинающимися с тире. 'cd -' эквивалентно 'cd'. И, опять же, нет «команды cd», она встроена в вашу оболочку, и детали зависят от того, какую оболочку вы используете. Например, 'zsh' ведет себя по-разному. – Schwern

2

cd является встроенной командой оболочки.

Вы можете открыть справочную страницу для cd на Bash с

$ help cd 

который в настоящее время показывает (Ubuntu 16.04):

$ help cd 
cd: cd [-L|[-P [-e]] [[email protected]]] [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 
     [email protected] 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, затем Enter и нажав n дважды получает меня к третьему экземпляру подстроки, и помощь, которая гласит:

cd [-L|[-P [-e]] [[email protected]]] [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 
      [email protected] 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. 

Ищут аргумент - о седьмой строке с конца.

Обратите внимание, что нет аргумента --, который, по-видимому, означает, что он фактически игнорирует его.

Смежные вопросы