Running shell commands

To interact with the operating system from within the Julia REPL, there are a few helper functions available, as follows:

  • pwd(): this function prints the current directory, for example, "d:\\test"
  • cd("d:\\test\\week1"): this function helps to navigate to subdirectories
  • ;in the interactive shell, you can also use shell mode using the ; modifier, for example: ; cd folder: navigates to folder

However, what if you want to run a shell command by using the operating system (the OS)? Julia offers efficient shell integration through the run function, which takes an object of type Cmd, defined by enclosing a command string in backticks (``).

The following are some examples for Linux or macOS X (at the time of writing: ...

Get Julia 1.0 Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.