I'm trying to use Java's ProcessBuilder
class to execute a command that has a pipe in it. For example:
ls -l | grep foo
However, I get an error:
ls: |: no such file or directory
Followed by:
ls: grep: no such file or directory
Even though that command works perfectly from the command line, I can not get ProcessBuilder
to execute a command that redirects its output to another.
Is there any way to accomplish this?
See Question&Answers more detail:os