0
我正在执行命令以便将日志消息写入SD卡上的文件。这是已经工作:在android中执行管道命令
String command = "logcat -f /storage/sdcard1/test.log";
Process logcatProcess = Runtime.getRuntime().exec(command);
现在我要过滤通过grep的输出日志将其写入文件中像这样前:
String[] command = {
"/system/bin/sh",
"-c",
"logcat | grep -i Test01 >> /storage/sdcard1/test.log"
};
Process logcatProcess = Runtime.getRuntime().exec(command);
当我从上面创建的文件运行的代码,但没有内容。系统上肯定安装了grep
命令。这里有什么问题?