pwd() -> AbstractString

Get the current working directory.


In the Julia programming language, the pwd() function is used to retrieve the current working directory.

julia> pwd()

Common examples of its use:

  1. Print the current working directory:

    julia> println(pwd())

    This example prints the current working directory to the console.

  2. Store the current working directory in a variable:

    julia> current_dir = pwd()

    It assigns the current working directory to the variable current_dir for later use.

  3. Change the directory and retrieve the updated current working directory:
    julia> cd("/path/to/new/directory")
    julia> println(pwd())

    This example changes the directory to /path/to/new/directory and then prints the updated current working directory.

Common mistake example:

julia> current_dir = pwd

In this example, the mistake is missing the parentheses () when calling pwd(). Without the parentheses, pwd refers to the function itself rather than invoking it. Always remember to include () when calling functions in Julia.

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: