I have written this code which should execute a command on shell to search pattern ">" in a text file , when I try same command on shell it works fine but when I try execute same command using java , it doesn't work for me as buffered reader returns null.Can somebody tell that what I have done wrong in this.
Code:
String filename="/home/abhijeet/sample.txt";
Process contigcount_p;
String command_to_count="grep \">\" "+filename+" | wc -l";
System.out.println("command for counting contigs "+command_to_count);
contigcount_p=Runtime.getRuntime().exec(command_to_count);
contigcount_p.wait();
BufferedReader reader =
new BufferedReader(new InputStreamReader(contigcount_p.getInputStream()));
System.out.println("chkk buffer"+reader.readLine());