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
命令。這裏有什麼問題?