This should work:
ProcessBuilder b = new ProcessBuilder("/bin/sh", "-c", "ls -l| grep foo");
To execute a pipeline, you have to invoke a shell, and then run your commands inside that shell.
More Related Contents:
- Including all the jars in a directory within the Java classpath
- How do I parse command line arguments in Java?
- Running Command Line in Java [duplicate]
- Run a JAR file from the command line and specify classpath
- How to invoke a Linux shell command from Java
- Build Eclipse Java Project from Command Line
- How to run TestNG from command line
- Java Command line arguments
- Run single test from a JUnit class using command-line
- Running java in package from command line
- Catching Ctrl+C in Java
- Command line progress bar in Java
- Run class in Jar file
- Can’t find/install libXtst.so.6?
- Hide input on command line
- changing the working-directory of command from java
- Running a JAR file without directly calling `java`
- How to compile java package structures using javac
- Compiling multiple packages using the command line in Java
- How to interrupt java.util.Scanner nextLine call
- When I run the .jar, I get a “No lwjgl in java.library.path” error
- Best Way to Gracefully Shutdown a Java Command Line Program
- Java key listener in Commandline
- How to force a jar to use(or the jvm that jar runs in) utf-8 instead of the system’s default encoding
- How to launch JUnit 5 (Platform) from the command line (without Maven/Gradle)?
- Testing console based applications/programs – Java
- Command Line Pipe Input in Java
- What’s the difference between -cp and -classpath
- Java exec() does not return expected result of pipes’ connected commands
- The best CLI parser for Java [duplicate]