Quantcast
Channel: command
Viewing all articles
Browse latest Browse all 11

How to run shell commands from the Scala REPL

$
0
0

How to run shell commands from the Scala REPL

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 14.4, “How to run a shell command from the Scala REPL.”

Problem

You want to be able to run a shell command from within the Scala REPL, such as listing the files in the current directory.

Solution

Run the command using the :sh REPL command, then print the output. The following example shows how to run the Unix ls -al command from within the REPL, and then show the results of the command:


Viewing all articles
Browse latest Browse all 11

Latest Images

Trending Articles





Latest Images