I want to grep the adb logcat & write the output to a text file. If I just do
./adb logcat > std.txt
it writes the entire log to the text file & If I do
./adb logcat | grep ABC
it prints all lines containing ABC to my terminal. But now I wish to search for ABC & write only these lines to a text file.
./adb logcat | grep ABC > std.txt
doesn't work. Plz help.
I think there is a problem with grep buffering. You can try something like this:
./adb logcat | grep --line-buffered ABC > std.txt
It should be the same problem for chained grep.
EDIT: A similar question can be found here: Why no output is shown when using grep twice?.