Consider the following code:
String commandf = \"ls /etc | grep release\"; try { // Execute the command and wait for it to complete Process child =
@Kaj accepted answer is for linux. This is the equivalent one for Windows:
String[] cmd = { "cmd", "/C", "dir /B | findstr /R /C:"release"" }; Process p = Runtime.getRuntime().exec(cmd);