Julia's ecosystem comes with a built-in package called File.jl that provides a wide range of methods that allow us to manage and handle operations with the filesystem. Julia provides a full-featured, integrated, and interactive shell read-eval-print loop (REPL) for running these methods. Also, Julia includes
Commands | Purpose | Descriptions |
| Redirecting | The |
| Pipelining | Julia pipes the output from both of the echo commands to the sort program. |
Let's explore the commands available to set a working directory in Julia:
pwd
: Return the current working directory in string format.
The syntax of this command is pwd()
.
cd
: Also known as the current directory, this is used to set the current working directory. If invoked without arguments, it defaults to the home directory.
This command has two methods of invocation, which are:
cd(dir)
: In this, dir
represents the path of the targeted directory.
cd(func,dir)
: With this advanced mode, the current working directory will be temporarily replaced with dir
, then the function func
will be applied, and finally, the original directory will be restored.
Now, let's explore the detailed process of setting up a working directory in Julia.
Step 1: Type the julia
command in order to start it in command-line REPL mode.
Step 2: Run the command pwd()
to obtain Julia's current working directory as shown below:
The screenshot above shows that Julia's current working directory is the root folder.
Step 3: Run the mkdir
command to create a directory called "Julia_Projects" reserved for our Julia workspace:
Step 4: Run the cd
command to change Julia's working directory to the one previously created, as shown below:
Step 5: Verify the move to the new directory by running the pwd()
command again as displayed below:
Let's run all the aforementioned commands in the given terminal below.
Free Resources