bash-hackers-wiki/docs/commands/builtin/cd.md
Hanson Char b75c3a588b Fix hyperlinks of markdown pages at depth 3
find docs/ -depth 3  -name '*.md' | xargs grep '(.*/' -l | \
  xargs -I{} \
  sed -i '' \
  -e 's%(/\([^/#).][^/#).]*\)/\([^/#).][^/#).]*\)\(.md\)\{0\})%(../../\1/\2.md)%g' \
  -e 's%(/\([^/#).][^/#).]*\)/\([^/#).][^/#).]*\)#\([a-zA-Z_-][0-9a-zA-Z_-]*\))%(../../\1/\2.md#\3)%g' \
  -e 's%(/\([^/#).][^/#).]*\)/\([^/#).][^/#).]*\)/\([^/#).][^/#).]*\)\(.md\)\{0\})%(../../\1/\2/\3.md)%g' \
  -e 's%(/\([^/#).][^/#).]*\)/\([^/#).][^/#).]*\)/\([^/#).][^/#).]*\)#\([a-zA-Z_-][0-9a-zA-Z_-]*\))%(../../\1/\2/\3.md#\4)%g' \
  -e 's%](\([^:.>)#][^:.>)#]*\))%](../../\1.md)%g' \
  -e 's%](\([^:.>)#][^:.>)#]*\)#\([^:.>)#][^:.>)#]*\))%](../../\1.md#\2)%g' \
  {}

Related to https://github.com/flokoe/bash-hackers-wiki/issues/10
2024-01-28 17:26:57 -08:00

1.7 KiB

The cd builtin command

Synopsis

cd [-L|-P] [DIRECTORY]

cd -

Description

The cd builtin command is used to change the current working directory

  • to the given directory (cd DIRECTORY)
  • to the previous working directory (cd -) as saved in the OLDPWD shell variable
  • to the user's home directory as specified in the HOME environment variable (when used without a DIRECTORY argument)

The cd builtin command searches the directories listed in CDPATH for a matching directory.

The default behaviour is to follow symbolic links unless the -P option is given or the shell is configured to do so (see the -P option of the set builtin command).

Options

Option Description


-L Follow symbolic links (default) -P Do not follow symbolic links -@ Browse a file's extended attributed, if supported

Exit status

  • true if the directory was changed successfully
  • false if a change to the home directory was requested, but HOME is unset
  • false if anything else goes wrong

Examples

Change the working directory to the user's home directory

cd

Change the working directory to the previous directory

cd -

Portability considerations

See also