I want to execute echo 'obase=94; 100' | bc >>out.txt for that I have used
String[] cmd = {"echo" , "'obase=94; 100'" , " | bc"};
new ProcessBuilder().command(cmd).redirectOutput(ProcessBuilder.Redirect.appendTo(new File("out.txt"))).start();
Inside out.txt I see 'obase=94; 100' | bc' instead of 01 06
Where I am going wrong?
| needs to be interpreted by a shell.
String[] cmd = {"bash", "-c", "echo 'obase=94; 100' | bc"};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With