Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multi-line commands in Julia

Tags:

shell

julia

You can run commands in Julia using the following syntax:

run(`echo 123`)

How can I easily run a long command with multiple arguments? It is convenient to split it up over multiple lines for readability purposes. Can I do this in Julia?

like image 769
m33lky Avatar asked May 21 '17 17:05

m33lky


People also ask

How to comment multiple lines in Julia?

Multi-Line Comments Julia multi-line comment is a piece of text enclosed in a delimiter (#=) on start of the comment and (=#) on the end of the comment. A multiline comment is useful when the comment text does not fit into one line; therefore needs to span across lines.

What is Shell in Julia?

Shell Mode Shell Mode. Typing ; at the beginning of a line enters shell mode. This changes the Julia REPL to run bash commands instead of Julia. In shell mode, the REPL acts like a Bash shell and you can enter your standard bash commands like ls , cd , mkdir , and others.


1 Answers

Julia automatically continues parsing in the next line if the current expression is incomplete, e.g.,

julia> 1 +
       2
3

Therefore, you can simply do

julia> run(`
           echo 
           123
           345
           678
       `)
123 345 678
like image 100
tim Avatar answered Oct 04 '22 13:10

tim