android – How to filter and redirect adb logcat output to a file in real-time?

I’m currently capturing Android logs using the following command:

adb logcat > ~/Desktop/logcat.txt

After stopping the log capture, I filter the logs with:

cat ~/Desktop/logcat.txt | grep "Sync execution" > ~/Desktop/logcatFiltered.txt

However, I’d like to combine these steps to filter adb logcat output in real-time and directly save the filtered lines to a file. I tried:

adb logcat > ~/Desktop/logcat.txt | grep "Sync execution" > ~/Desktop/logcatFiltered.txt

But it results in a blank file. How can I achieve real-time filtering and redirection?

Read more here: Source link