-
Book Overview & Buying
-
Table Of Contents
Getting started with Julia Programming Language
By :
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 the shell mode using the ; modifier:
; ls: This prints, for example, file1.txt shell.jl test.txt tosort.txt
; mkdir folder: This makes a directory named folder
; cd folder: This helps to navigate to folder
However, what if you want to run a shell command by the operating system (the OS)? Julia offers an efficient shell integration through the run function, which takes an object of type Cmd that is defined by enclosing a command string in backticks (``):
# Code in Chapter 9\shell.jl: cmd = `echo Julia is smart` typeof(cmd) #> Cmd run(cmd) # returns Julia is smart run(`date`) #> Sun Oct 12 09:44:50 GMT 2014 cmd = `cat file1.txt` run(cmd) ...
Change the font size
Change margin width
Change background colour