Skip to main content
Version: 2.0.x


You can pipe the output of one process as the input to another. For example, if you want to return a list of all running Java process IDs, you can do the following:


val processes = Command("ps", "-ef").stream
val javaProcesses = Command("grep", "java").stdin(ProcessInput.fromStream(processes)).stream
val processIds = Command("awk", "{print $2}").stdin(ProcessInput.fromStream(javaProcesses)).lines

Using the pipe operator

Rather than connecting the outputs and inputs manually, you can use the | operator (or its named equivalent, pipe) like so:

(Command("ps", "-ef") | Command("grep", "java") | Command("awk", "{print $2}")).lines