cd(dir::AbstractString)
cd([dir::AbstractString=homedir()])
Set the current working directory.
Examples
-
Change directory and execute a function:
julia> function print_current_dir() println(pwd()) end julia> cd(print_current_dir, dir="/path/to/directory") /path/to/directory
This example changes the current working directory to
/path/to/directory
and executes theprint_current_dir
function, which prints the current working directory. -
Change directory using the default home directory:
julia> cd(print_current_dir) /home/user
In this case, the current working directory is changed to the home directory (
homedir()
) and theprint_current_dir
function is executed.
Common mistake example:
julia> cd(print_current_dir, "/path/to/invalid/directory")
ERROR: SystemError: chdir: no such file or directory (ENOENT)
In this example, the directory path provided (/path/to/invalid/directory
) does not exist, resulting in a SystemError
. Make sure to provide a valid directory path to the cd
function to avoid such errors.
See Also
addprocs, atexit, cd, clipboard, EnvHash, exit, getpid, peakflops, ProcessExitedException, process_exited, process_running, procs, quit, readandwrite, redirect_stdout, rmprocs, run, setenv, spawn, withenv,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.