Bash - Print Working directory (pwd)

> Procedural Languages > Bash Shell and (Unix|Linux) Utilities (XCU) > Bash - File System

1 - About

pwd displays the absolute pathname of the current directory in bash.

Advertising

3 - Syntax

pwd [-LP]

where:

  • -P will print the pathname with no symbolic links or the -o physical option to the set builtin command is enabled.
  • -L will print the pathname that may contain symbolic links.

The return status is 0 unless an error occurs while reading the name of the current directory or an invalid option is supplied.

4 - Logical [default] and Physical working directories

To print the Logical [default] and Physical working directories, use pwd -L and pwd -P

$ pwd -L
/tmp/bar/baz
$ pwd -P
/tmp/foo
lang/bash/fs/pwd.txt · Last modified: 2017/02/22 11:04 by gerardnico