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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.