Having some issue on using adb, grep and cut. I have a command below
adb logcat | grep MYTEXT
this has result of several text that has ":" separating them.
If I use the below to remove text before ":", it doesn't work.
adb logcat | grep MYTEXT | cut -d':' -f 2-
However if I first dump into a file and then do the same. It works.
adb logcat > mylog.out
cat mylog.out | grep MYTEST | cut -d':' -f 2-
I can use this approach as workaround, but I would prefer not to need to dump to mylog.out first as temporary step in my script.
Anyone to enlighten? Thanks!
Assuming no typos (MYTEXT
/MYTEST
) or other similar issues are involved here then this is likely related to buffering of data and volume of data.
Telling grep
to buffer its output by lines with the --line-buffered
option will probably help here.
adb logcat | grep --line-buffered MYTEXT | cut -d':' -f 2-
As might using the unbuffer
or stdbuf
utilities.