I am trying to remove the text between two line numbers. I am using the dmesg
in Ubuntu, which is a really long command, so I would like to trim the string between line 0 3 but leave 4 through 5, etc. Here is my code:
try {
Process terminal = Runtime.getRuntime().exec("dmesg");
BufferedReader in = new BufferedReader(new InputStreamReader(terminal.getInputStream()));
String line;
String output = "";
while((line = in.readLine()) != null) {
output += line + "\n";
}
System.out.println(output);
in.close();
} catch(Exception exc) {
System.err.println("An error occurred while executing a command in the terminal. Error:\n" + exc);
}
Any suggestions? Thanks!