I am trying to run below code:
public class StandOnLinux {
public static void main(String[] args) throws IOException {
//String commandToBeExecuted = "git blame '"+files[i]+"' | grep "+revision+" | awk '{print $7}'";
//String commandToBeExecuted = "git --git-dir D:\\code_coverage\\.git blame src\\RunCodeCoverage.java | grep 'e4ecfbe'"; git blame --git-dir D:/code_coverage/.git src/RunCodeCoverage.java| grep 59e3fdc | gawk '{print $7}'
String commandToBeExecuted = "git blame StandOnLinux.java --grep=\"e8a93e7d\"";
String temp = "";
File file = new File("C:/Program Files (x86)/Git/bin");
System.out.println(commandToBeExecuted);
Process p = Runtime.getRuntime().exec(commandToBeExecuted);
//Process p = Runtime.getRuntime().exec(new String[]{"cmd", "/c", commandToBeExecuted});
//Process p =Runtime.getRuntime().exec(commandToBeExecuted, null, file);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(
p.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(
p.getErrorStream()));
while((temp = stdInput.readLine()) != null) {
System.out.println(temp);
}
while((temp = stdError.readLine()) != null) {
System.out.println(temp);
}
}
}
But this gives me results without grepping the output as mentioned in grep.
Can anyone tell what is wrong i am doing in this code?
Running this code on Linux machine.