I try to run the following command to get only a line of memory status.
Runtime.getRuntime().exec("free -m | grep 'Mem'");
But it returns all lines of result. The command after the vertical bar is not processed. I also try:
Runtime.getRuntime().exec(new String[] { "free", "-m", "|", "grep", "Mem" });
And it doesn't work either.